From 123d18b5c76a54dfeb6eb3691670bed5a5585859 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Thu, 3 Oct 2019 20:22:25 +0000 Subject: [PATCH] tftp: fix two minor Coverity CIDs Reported by: Coverity CID 1394842: file descriptor leak in an error path CID 1007603: single byte array overflow MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D21695 --- usr.bin/tftp/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index 92b4d37f5785..5644132fe920 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -491,6 +491,7 @@ put(int argc, char *argv[]) if (fstat(fd, &sb) < 0) { warn("%s", cp); + close(fd); return; } asprintf(&options[OPT_TSIZE].o_request, "%ju", sb.st_size); @@ -746,7 +747,7 @@ command(bool interactive, EditLine *el, History *hist, HistEvent *hep) exit(0); len = MIN(MAXLINE, num); memcpy(line, bp, len); - line[len] = '\0'; + line[len - 1] = '\0'; history(hist, hep, H_ENTER, bp); } else { line[0] = 0;