INN commit: branches/2.6 (frontends/inews.c lib/clientlib.c)

INN Commit rra at isc.org
Sun May 10 12:58:37 UTC 2020


    Date: Sunday, May 10, 2020 @ 05:58:37
  Author: iulius
Revision: 10365

Fix build with GCC 10.1

Ensure that ser_line is at least 4-byte long.
And that there is enough room in buff to copy the path.

Modified:
  branches/2.6/frontends/inews.c
  branches/2.6/lib/clientlib.c

-------------------+
 frontends/inews.c |    2 +-
 lib/clientlib.c   |   29 ++++++++++++++++-------------
 2 files changed, 17 insertions(+), 14 deletions(-)

Modified: frontends/inews.c
===================================================================
--- frontends/inews.c	2020-05-10 12:57:48 UTC (rev 10364)
+++ frontends/inews.c	2020-05-10 12:58:37 UTC (rev 10365)
@@ -685,7 +685,7 @@
     *linesp = 0;
     if (strlen(homedir) > sizeof(buff) - 14)
         die("home directory path too long");
-    sprintf(buff, "%s/.signature", homedir);
+    snprintf(buff, sizeof(buff), "%s/.signature", homedir);
     if ((F = fopen(buff, "r")) == NULL) {
 	if (errno == ENOENT)
 	    return article;

Modified: lib/clientlib.c
===================================================================
--- lib/clientlib.c	2020-05-10 12:57:48 UTC (rev 10364)
+++ lib/clientlib.c	2020-05-10 12:58:37 UTC (rev 10365)
@@ -83,19 +83,22 @@
     default:
 	printf("Unknown response code %d from %s.\n", response, host);
 	return -1;
-     case NNTP_FAIL_TERMINATING:
-	if (atoi(ser_line) == response) {
-	    p = &ser_line[strlen(ser_line) - 1];
-	    if (*p == '\n' && *--p == '\r')
-		*p = '\0';
-	    if (p > &ser_line[3]) {
-		printf("News server %s unavailable: %s\n", host,
-			&ser_line[4]);
-		return -1;
-	    }
-	}
-	printf("News server %s unavailable, try later.\n", host);
-	return -1;
+    case NNTP_FAIL_TERMINATING:
+        if (atoi(ser_line) == response) {
+            size_t ser_line_len = strlen(ser_line);
+            if (ser_line_len > 4) {
+                p = &ser_line[ser_line_len - 1];
+                if (*p == '\n' && *--p == '\r')
+                    *p = '\0';
+                if (p > &ser_line[3]) {
+                    printf("News server %s unavailable: %s\n", host,
+                           &ser_line[4]);
+                    return -1;
+                }
+            }
+        }
+        printf("News server %s unavailable, try later.\n", host);
+        return -1;
     case NNTP_ERR_ACCESS:
 	printf(CANTUSE, host);
 	return -1;



More information about the inn-committers mailing list