aboutsummaryrefslogtreecommitdiff
path: root/libexec/tftpd/tftp-utils.c
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2018-07-22 16:14:30 +0000
committerAlan Somers <asomers@FreeBSD.org>2018-07-22 16:14:30 +0000
commit3c0fa265346ec04fc8277fba9c3fe28d1e26068a (patch)
tree3b1a19664ad53961d92a5995170e2f877111cc7d /libexec/tftpd/tftp-utils.c
parent12395dc9f6bfd1e40ac41ef8fb6af966ad647a2e (diff)
downloadsrc-3c0fa265346ec04fc8277fba9c3fe28d1e26068a.tar.gz
src-3c0fa265346ec04fc8277fba9c3fe28d1e26068a.zip
Fix multiple Coverity warnings in tftpd(8)
* Initialize uninitialized variable (CID 1006502) * strcpy => strlcpy (CID 1006792, 1006791, 1006790) * Check function return values (CID 1009442, 1009441, 1009440) * Delete dead code in receive_packet (not reported by Coverity) * Remove redundant alarm(3) in receive_packet (not reported by Coverity) Reported by: Coverity CID: 1006502, 1006792, 1006791, 1006790, 1009442, 1009441, 1009440 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D11287
Notes
Notes: svn path=/head/; revision=336605
Diffstat (limited to 'libexec/tftpd/tftp-utils.c')
-rw-r--r--libexec/tftpd/tftp-utils.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libexec/tftpd/tftp-utils.c b/libexec/tftpd/tftp-utils.c
index f578a7e6d831..f9f8f4dc922a 100644
--- a/libexec/tftpd/tftp-utils.c
+++ b/libexec/tftpd/tftp-utils.c
@@ -270,11 +270,13 @@ char *
rp_strerror(int error)
{
static char s[100];
+ size_t space = sizeof(s);
int i = 0;
while (rp_errors[i].desc != NULL) {
if (rp_errors[i].error == error) {
- strcpy(s, rp_errors[i].desc);
+ strlcpy(s, rp_errors[i].desc, space);
+ space -= strlen(rp_errors[i].desc);
}
i++;
}