clausklein / rpms / tftp

Forked from rpms/tftp 5 years ago
Clone

Blame SOURCES/tftp-hpa-0.49-fortify-strcpy-crash.patch

91c661
diff -urN tftp-hpa-0.49.orig/tftp/tftp.c tftp-hpa-0.49/tftp/tftp.c
91c661
--- tftp-hpa-0.49.orig/tftp/tftp.c	2008-10-20 18:08:31.000000000 -0400
91c661
+++ tftp-hpa-0.49/tftp/tftp.c	2009-08-05 09:47:18.072585848 -0400
91c661
@@ -279,15 +279,16 @@
91c661
             struct tftphdr *tp, const char *mode)
91c661
 {
91c661
     char *cp;
91c661
+    size_t len;
91c661
 
91c661
     tp->th_opcode = htons((u_short) request);
91c661
     cp = (char *)&(tp->th_stuff);
91c661
-    strcpy(cp, name);
91c661
-    cp += strlen(name);
91c661
-    *cp++ = '\0';
91c661
-    strcpy(cp, mode);
91c661
-    cp += strlen(mode);
91c661
-    *cp++ = '\0';
91c661
+    len = strlen(name) + 1;
91c661
+    memcpy(cp, name, len);
91c661
+    cp += len;
91c661
+    len = strlen(mode) + 1;
91c661
+    memcpy(cp, mode, len);
91c661
+    cp += len;
91c661
     return (cp - (char *)tp);
91c661
 }
91c661