aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Howarth <paul@city-fan.org>2010-12-17 19:07:45 +0100
committerKamil Dudka <kdudka@redhat.com>2010-12-17 19:08:43 +0100
commit1df74d886d764115944d40fbc79bfd51ec7d714a (patch)
treed8b3be1cf7b390bf590c4c605e32ad5fed28773f
parent76c54bd1291bc93ed153bb4e8c8dc6e0122f6784 (diff)
tftpd: avoid buffer overflow report from glibc
-rw-r--r--tests/server/tftpd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c
index b9a0562ee..701b3e946 100644
--- a/tests/server/tftpd.c
+++ b/tests/server/tftpd.c
@@ -1291,9 +1291,11 @@ static void nak(int error)
pe->e_msg = strerror(error - 100);
tp->th_code = EUNDEF; /* set 'undef' errorcode */
}
- strcpy(tp->th_msg, pe->e_msg);
length = (int)strlen(pe->e_msg);
- tp->th_msg[length] = '\0';
+
+ /* we use memcpy() instead of strcpy() in order to avoid buffer overflow
+ * report from glibc with FORTIFY_SOURCE */
+ memcpy(tp->th_msg, pe->e_msg, length + 1);
length += 5;
if (swrite(peer, &buf.storage[0], length) != length)
logmsg("nak: fail\n");