lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 16 Nov 2009 22:24:55 +0100
From:	Roel Kluin <roel.kluin@...il.com>
To:	Roel Kluin <roel.kluin@...il.com>
CC:	Randy Dunlap <rdunlap@...otime.net>, linux-doc@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>,
	David Wagner <daw@...berkeley.edu>
Subject: Re: [PATCH] Documentation: Fix NUL termination of strncpy

Ensure the copied strings are NUL terminated.

Signed-off-by: Roel Kluin <roel.kluin@...il.com>
---
>> Rationale (please correct me if I'm wrong):

I was confused. strncpy requires explicit NUL termination
or it depends on a NUL in the source string.

 Documentation/accounting/getdelays.c               |    3 ++-
 Documentation/hwmon/hpfall.c                       |    3 ++-
 Documentation/networking/radiotap-headers.txt      |    2 +-
 .../networking/timestamping/timestamping.c         |    6 ++++--
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
index 6e25c26..ba54b19 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -303,7 +303,8 @@ int main(int argc, char *argv[])
 				err(1, "Invalid rcv buf size\n");
 			break;
 		case 'm':
-			strncpy(cpumask, optarg, sizeof(cpumask));
+			strncpy(cpumask, optarg, sizeof(cpumask) - 1);
+			cpumask[sizeof(cpumask) - 1] = '\0';
 			maskset = 1;
 			printf("cpumask %s maskset %d\n", cpumask, maskset);
 			break;
diff --git a/Documentation/hwmon/hpfall.c b/Documentation/hwmon/hpfall.c
index 681ec22..4a06c06 100644
--- a/Documentation/hwmon/hpfall.c
+++ b/Documentation/hwmon/hpfall.c
@@ -27,7 +27,8 @@ int set_unload_heads_path(char *device)
 
 	if (strlen(device) <= 5 || strncmp(device, "/dev/", 5) != 0)
 		return -EINVAL;
-	strncpy(devname, device + 5, sizeof(devname));
+	strncpy(devname, device + 5, sizeof(devname) - 1);
+	devname[sizeof(devname) - 1] = '\0';
 
 	snprintf(unload_heads_path, sizeof(unload_heads_path),
 				"/sys/block/%s/device/unload_heads", devname);
diff --git a/Documentation/networking/radiotap-headers.txt b/Documentation/networking/radiotap-headers.txt
index 953331c..447e004 100644
--- a/Documentation/networking/radiotap-headers.txt
+++ b/Documentation/networking/radiotap-headers.txt
@@ -126,7 +126,7 @@ int MyFunction(u8 * buf, int buflen)
 
 		case IEEE80211_RADIOTAP_ANTENNA:
 			/* radiotap uses 0 for 1st ant */
-			antenna = *iterator.this_arg);
+			antenna = *iterator.this_arg;
 			break;
 
 		case IEEE80211_RADIOTAP_DBM_TX_POWER:
diff --git a/Documentation/networking/timestamping/timestamping.c b/Documentation/networking/timestamping/timestamping.c
index a7936fe..e2a17a4 100644
--- a/Documentation/networking/timestamping/timestamping.c
+++ b/Documentation/networking/timestamping/timestamping.c
@@ -374,12 +374,14 @@ int main(int argc, char **argv)
 		bail("socket");
 
 	memset(&device, 0, sizeof(device));
-	strncpy(device.ifr_name, interface, sizeof(device.ifr_name));
+	strncpy(device.ifr_name, interface, sizeof(device.ifr_name) - 1);
+	device.ifr_name[sizeof(device.ifr_name) - 1] = '\0';
 	if (ioctl(sock, SIOCGIFADDR, &device) < 0)
 		bail("getting interface IP address");
 
 	memset(&hwtstamp, 0, sizeof(hwtstamp));
-	strncpy(hwtstamp.ifr_name, interface, sizeof(hwtstamp.ifr_name));
+	strncpy(hwtstamp.ifr_name, interface, sizeof(hwtstamp.ifr_name) - 1);
+	hwtstamp.ifr_name[sizeof(hwtstamp.ifr_name) - 1] = '\0';
 	hwtstamp.ifr_data = (void *)&hwconfig;
 	memset(&hwconfig, 0, sizeof(hwconfig));
 	hwconfig.tx_type =
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ