Blame SOURCES/0002-Make-sure-strings-copied-by-strncpy-are-null-termina.patch

3f7af7
From 695564da74fe7c95802f5bf59e442e23a2d7cbbf Mon Sep 17 00:00:00 2001
3f7af7
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
3f7af7
Date: Mon, 13 Aug 2018 14:39:43 +0200
3f7af7
Subject: [PATCH 2/7] Make sure strings copied by strncpy are null-terminated
3f7af7
MIME-Version: 1.0
3f7af7
Content-Type: text/plain; charset=UTF-8
3f7af7
Content-Transfer-Encoding: 8bit
3f7af7
3f7af7
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
3f7af7
---
3f7af7
 src/config.c  | 1 +
3f7af7
 src/dial.c    | 3 +++
3f7af7
 src/minicom.c | 3 +++
3f7af7
 src/script.c  | 2 ++
3f7af7
 src/updown.c  | 4 ++++
3f7af7
 5 files changed, 13 insertions(+)
3f7af7
3f7af7
diff --git a/src/config.c b/src/config.c
3f7af7
index 78b25aa..ea939c8 100644
3f7af7
--- a/src/config.c
3f7af7
+++ b/src/config.c
3f7af7
@@ -88,6 +88,7 @@ void read_parms(void)
3f7af7
   for (f = PROTO_BASE; f < MAXPROTO; f++) {
3f7af7
     if (P_PNAME(f)[0] && P_PIORED(f) != 'Y' && P_PIORED(f) != 'N') {
3f7af7
       strncpy(buf, P_PNAME(f) - 2, sizeof(buf));
3f7af7
+      buf[sizeof(buf) - 1] = '\0';
3f7af7
       strcpy(P_PNAME(f), buf);
3f7af7
       P_PIORED(f) = 'Y';
3f7af7
       P_PFULL(f) = 'N';
3f7af7
diff --git a/src/dial.c b/src/dial.c
3f7af7
index a90c1d2..a3337e5 100644
3f7af7
--- a/src/dial.c
3f7af7
+++ b/src/dial.c
3f7af7
@@ -829,8 +829,11 @@ static int v1_read(FILE *fp, struct dialent *d)
3f7af7
 
3f7af7
   memcpy(d->username, v1.username, sizeof(v1) - offsetof(struct v1_dialent, username));
3f7af7
   strncpy(d->name, v1.name, sizeof(d->name));
3f7af7
+  d->name[sizeof(d->name) - 1] = '\0';
3f7af7
   strncpy(d->number, v1.number, sizeof(d->number));
3f7af7
+  d->number[sizeof(d->number) - 1] = '\0';
3f7af7
   strncpy(d->script, v1.script, sizeof(d->script));
3f7af7
+  d->script[sizeof(d->script) - 1] = '\0';
3f7af7
   d->lastdate[0]=0;
3f7af7
   d->lasttime[0]=0;
3f7af7
   d->count=0;
3f7af7
diff --git a/src/minicom.c b/src/minicom.c
3f7af7
index 4eb47d4..876805a 100644
3f7af7
--- a/src/minicom.c
3f7af7
+++ b/src/minicom.c
3f7af7
@@ -1208,6 +1208,7 @@ int main(int argc, char **argv)
3f7af7
           break;
3f7af7
         case 't': /* Terminal type */
3f7af7
           strncpy(termtype, optarg, sizeof(termtype));
3f7af7
+          termtype[sizeof(termtype) - 1] = '\0';
3f7af7
 #ifdef __GLIBC__
3f7af7
           /* Bug in older libc's (< 4.5.26 I think) */
3f7af7
           if ((s = getenv("TERMCAP")) != NULL && *s != '/')
3f7af7
@@ -1322,7 +1323,9 @@ int main(int argc, char **argv)
3f7af7
     strncpy(homedir, pwd->pw_dir, sizeof(homedir));
3f7af7
   else
3f7af7
     strncpy(homedir, s, sizeof(homedir));
3f7af7
+  homedir[sizeof(homedir) - 1] = '\0';
3f7af7
   strncpy(username, pwd->pw_name, sizeof(username));
3f7af7
+  username[sizeof(username) - 1] = '\0';
3f7af7
 
3f7af7
   /* Get personal parameter file */
3f7af7
   snprintf(pparfile, sizeof(pparfile), "%s/.minirc.%s", homedir, use_port);
3f7af7
diff --git a/src/script.c b/src/script.c
3f7af7
index ee1284f..f7c4e3f 100644
3f7af7
--- a/src/script.c
3f7af7
+++ b/src/script.c
3f7af7
@@ -1099,12 +1099,14 @@ int main(int argc, char **argv)
3f7af7
 
3f7af7
   if (argc > 2) {
3f7af7
     strncpy(logfname, argv[2], sizeof(logfname));
3f7af7
+    logfname[sizeof(logfname) - 1] = '\0';
3f7af7
     if (argc > 3)
3f7af7
       strncpy(homedir, argv[3], sizeof(homedir));
3f7af7
     else if ((s = getenv("HOME")) != NULL)
3f7af7
       strncpy(homedir, s, sizeof(homedir));
3f7af7
     else
3f7af7
       homedir[0] = 0;
3f7af7
+    homedir[sizeof(homedir) - 1] = '\0';
3f7af7
   }
3f7af7
   else
3f7af7
     logfname[0] = 0;
3f7af7
diff --git a/src/updown.c b/src/updown.c
3f7af7
index 726328e..54442bb 100644
3f7af7
--- a/src/updown.c
3f7af7
+++ b/src/updown.c
3f7af7
@@ -386,6 +386,7 @@ void updown(int what, int nr)
3f7af7
             do_log("%s", trimbuf);
3f7af7
           } else if (!strncmp (buffirst, "Bytes", 5)) {
3f7af7
             strncpy (xfrstr, buf, sizeof(xfrstr));
3f7af7
+            xfrstr[sizeof(xfrstr) - 1] = '\0';
3f7af7
           }
3f7af7
           buffirst[0] = 0;
3f7af7
           trimbuf[0] = 0;
3f7af7
@@ -698,8 +699,11 @@ void runscript(int ask, const char *s, const char *l, const char *p)
3f7af7
     }
3f7af7
   } else {
3f7af7
     strncpy(scr_user, l, sizeof(scr_user));
3f7af7
+    scr_user[sizeof(scr_user) - 1] = '\0';
3f7af7
     strncpy(scr_name, s, sizeof(scr_name));
3f7af7
+    scr_name[sizeof(scr_name) - 1] = '\0';
3f7af7
     strncpy(scr_passwd, p, sizeof(scr_passwd));
3f7af7
+    scr_passwd[sizeof(scr_passwd) - 1] = '\0';
3f7af7
   }
3f7af7
   sprintf(scr_lines, "%d", (int) lines);  /* jl 13.09.97 */
3f7af7
 
3f7af7
-- 
3f7af7
2.14.4
3f7af7