]> diplodocus.org Git - nmh/commitdiff
fgets() reserves space for the NUL itself.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 30 Oct 2016 21:06:06 +0000 (21:06 +0000)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 30 Oct 2016 21:06:06 +0000 (21:06 +0000)
No need to knock one off the buffer size when calling it as that
suggests something special is going on.

sbr/ruserpass.c
uip/mhstoresbr.c
uip/post.c
uip/sendsbr.c

index 43784d528d02158c3050a90e88dfb836d613162d..1d946fa2008b7d818aa9a152a0c319bbb9dab1aa 100644 (file)
@@ -147,7 +147,7 @@ ruserpass(const char *host, char **aname, char **apass, int flags)
        }
        printf("Name (%s:%s): ", host, myname);
 
        }
        printf("Name (%s:%s): ", host, myname);
 
-       if (fgets(tmp, sizeof(tmp) - 1, stdin) == NULL) {
+       if (fgets(tmp, sizeof tmp, stdin) == NULL) {
            advise ("tmp", "fgets");
        }
         TrimSuffixC(tmp, '\n');
            advise ("tmp", "fgets");
        }
         TrimSuffixC(tmp, '\n');
index cab9cee76f933ac197cab7af1cce01bdc52a72b0..a2bc919e90cb5e63fb111bd60a5bd6e0c7e22b34 100644 (file)
@@ -835,7 +835,7 @@ losing:
        }
     }
 
        }
     }
 
-    while (fgets (buffer, sizeof(buffer) - 1, ct->c_fp)) {
+    while (fgets (buffer, sizeof buffer, ct->c_fp)) {
        if ((pos += strlen (buffer)) > last) {
            int diff;
 
        if ((pos += strlen (buffer)) > last) {
            int diff;
 
index bf1c042db6276a058440936459f41e4138071c33..9940fa71f3e6700b07edf5479a969cb85bce0667 100644 (file)
@@ -1527,7 +1527,7 @@ find_prefix (void)
     if ((in = fopen (tmpfil, "r")) == NULL)
        adios (tmpfil, "unable to re-open");
 
     if ((in = fopen (tmpfil, "r")) == NULL)
        adios (tmpfil, "unable to re-open");
 
-    while (fgets (buffer, sizeof(buffer) - 1, in))
+    while (fgets (buffer, sizeof buffer, in))
        if (buffer[0] == '-' && buffer[1] == '-') {
            char *cp;
 
        if (buffer[0] == '-' && buffer[1] == '-') {
            char *cp;
 
index 497c868b2bbfb229ae8f603b7a9da5ffc3e0db7a..33dd3451ee5c4c74350e8d40cf8a4e99e9af115b 100644 (file)
@@ -286,7 +286,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft,
 
     nparts = 1;
     pos = start;
 
     nparts = 1;
     pos = start;
-    while (fgets (buffer, sizeof(buffer) - 1, in)) {
+    while (fgets (buffer, sizeof buffer, in)) {
        long len;
 
        if ((pos += (len = strlen (buffer))) > CPERMSG) {
        long len;
 
        if ((pos += (len = strlen (buffer))) > CPERMSG) {
@@ -356,7 +356,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft,
        for (;;) {
            long len;
 
        for (;;) {
            long len;
 
-           if (!fgets (buffer, sizeof(buffer) - 1, in)) {
+           if (!fgets (buffer, sizeof buffer, in)) {
                if (partno == nparts)
                    break;
                adios (NULL, "premature eof");
                if (partno == nparts)
                    break;
                adios (NULL, "premature eof");