svn commit: r365042 - head/usr.sbin/ctld
Edward Tomasz Napierala
trasz at FreeBSD.org
Tue Sep 1 14:58:57 UTC 2020
Author: trasz
Date: Tue Sep 1 14:58:57 2020
New Revision: 365042
URL: https://svnweb.freebsd.org/changeset/base/365042
Log:
Make sure not to pass NULL to strtoul(3). The values come
from the kernel, but let's try to be on the safe side.
Reviewed by: mav
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26246
Modified:
head/usr.sbin/ctld/kernel.c
Modified: head/usr.sbin/ctld/kernel.c
==============================================================================
--- head/usr.sbin/ctld/kernel.c Tue Sep 1 14:52:39 2020 (r365041)
+++ head/usr.sbin/ctld/kernel.c Tue Sep 1 14:58:57 2020 (r365042)
@@ -238,10 +238,16 @@ cctl_end_element(void *user_data, const char *name)
cur_lun->backend_type = str;
str = NULL;
} else if (strcmp(name, "lun_type") == 0) {
+ if (str == NULL)
+ log_errx(1, "%s: %s missing its argument", __func__, name);
cur_lun->device_type = strtoull(str, NULL, 0);
} else if (strcmp(name, "size") == 0) {
+ if (str == NULL)
+ log_errx(1, "%s: %s missing its argument", __func__, name);
cur_lun->size_blocks = strtoull(str, NULL, 0);
} else if (strcmp(name, "blocksize") == 0) {
+ if (str == NULL)
+ log_errx(1, "%s: %s missing its argument", __func__, name);
cur_lun->blocksize = strtoul(str, NULL, 0);
} else if (strcmp(name, "serial_number") == 0) {
cur_lun->serial_number = str;
@@ -357,15 +363,23 @@ cctl_end_pelement(void *user_data, const char *name)
cur_port->port_name = str;
str = NULL;
} else if (strcmp(name, "physical_port") == 0) {
+ if (str == NULL)
+ log_errx(1, "%s: %s missing its argument", __func__, name);
cur_port->pp = strtoul(str, NULL, 0);
} else if (strcmp(name, "virtual_port") == 0) {
+ if (str == NULL)
+ log_errx(1, "%s: %s missing its argument", __func__, name);
cur_port->vp = strtoul(str, NULL, 0);
} else if (strcmp(name, "cfiscsi_target") == 0) {
cur_port->cfiscsi_target = str;
str = NULL;
} else if (strcmp(name, "cfiscsi_state") == 0) {
+ if (str == NULL)
+ log_errx(1, "%s: %s missing its argument", __func__, name);
cur_port->cfiscsi_state = strtoul(str, NULL, 0);
} else if (strcmp(name, "cfiscsi_portal_group_tag") == 0) {
+ if (str == NULL)
+ log_errx(1, "%s: %s missing its argument", __func__, name);
cur_port->cfiscsi_portal_group_tag = strtoul(str, NULL, 0);
} else if (strcmp(name, "ctld_portal_group_name") == 0) {
cur_port->ctld_portal_group_name = str;
More information about the svn-src-all
mailing list