summaryrefslogtreecommitdiff
path: root/core/shadow/shadow-strncpy-usage.patch
blob: 46df74ace733b42204bcf34f2346291d857eabab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
diff -ur shadow-4.1.4.3.orig/src/login.c shadow-4.1.4.3/src/login.c
--- shadow-4.1.4.3.orig/src/login.c	2011-03-05 22:17:10.032524948 -0800
+++ shadow-4.1.4.3/src/login.c	2011-03-05 22:17:59.154342059 -0800
@@ -748,8 +748,9 @@
 			          sizeof (loginprompt),
 			          _("%s login: "), hostn);
 		} else {
+		        loginprompt[sizeof (loginprompt) - 1] = '\0';
 			strncpy (loginprompt, _("login: "),
-			         sizeof (loginprompt));
+			         sizeof (loginprompt) - 1);
 		}
 
 		retcode = pam_set_item (pamh, PAM_USER_PROMPT, loginprompt);
diff -ur shadow-4.1.4.3.orig/src/usermod.c shadow-4.1.4.3/src/usermod.c
--- shadow-4.1.4.3.orig/src/usermod.c	2011-03-05 22:17:10.029191265 -0800
+++ shadow-4.1.4.3/src/usermod.c	2011-03-05 22:18:42.665576968 -0800
@@ -182,7 +182,8 @@
 	struct tm *tp;
 
 	if ((negativ != NULL) && (date < 0)) {
-		strncpy (buf, negativ, maxsize);
+	        buf[maxsize - 1] = '\0';
+		strncpy (buf, negativ, maxsize - 1);
 	} else {
 		time_t t = (time_t) date;
 		tp = gmtime (&t);