1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

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
This commit is contained in:
Edward Tomasz Napierala 2020-09-01 14:58:57 +00:00
parent fb0d1c6980
commit e352957180
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=365042

View File

@ -238,10 +238,16 @@ cctl_end_element(void *user_data, const char *name)
cur_lun->backend_type = str; cur_lun->backend_type = str;
str = NULL; str = NULL;
} else if (strcmp(name, "lun_type") == 0) { } 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); cur_lun->device_type = strtoull(str, NULL, 0);
} else if (strcmp(name, "size") == 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); cur_lun->size_blocks = strtoull(str, NULL, 0);
} else if (strcmp(name, "blocksize") == 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); cur_lun->blocksize = strtoul(str, NULL, 0);
} else if (strcmp(name, "serial_number") == 0) { } else if (strcmp(name, "serial_number") == 0) {
cur_lun->serial_number = str; cur_lun->serial_number = str;
@ -357,15 +363,23 @@ cctl_end_pelement(void *user_data, const char *name)
cur_port->port_name = str; cur_port->port_name = str;
str = NULL; str = NULL;
} else if (strcmp(name, "physical_port") == 0) { } 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); cur_port->pp = strtoul(str, NULL, 0);
} else if (strcmp(name, "virtual_port") == 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); cur_port->vp = strtoul(str, NULL, 0);
} else if (strcmp(name, "cfiscsi_target") == 0) { } else if (strcmp(name, "cfiscsi_target") == 0) {
cur_port->cfiscsi_target = str; cur_port->cfiscsi_target = str;
str = NULL; str = NULL;
} else if (strcmp(name, "cfiscsi_state") == 0) { } 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); cur_port->cfiscsi_state = strtoul(str, NULL, 0);
} else if (strcmp(name, "cfiscsi_portal_group_tag") == 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); cur_port->cfiscsi_portal_group_tag = strtoul(str, NULL, 0);
} else if (strcmp(name, "ctld_portal_group_name") == 0) { } else if (strcmp(name, "ctld_portal_group_name") == 0) {
cur_port->ctld_portal_group_name = str; cur_port->ctld_portal_group_name = str;