Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Sep 2020 14:58:57 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r365042 - head/usr.sbin/ctld
Message-ID:  <202009011458.081Ewvor081411@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009011458.081Ewvor081411>