]> 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 43784d5..1d946fa 100644 (file)
@@ -147,7 +147,7 @@ ruserpass(const char *host, char **aname, char **apass, int flags)
        }
        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');
index cab9cee..a2bc919 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;
 
index bf1c042..9940fa7 100644 (file)
@@ -1527,7 +1527,7 @@ find_prefix (void)
     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;
 
index 497c868..33dd345 100644 (file)
@@ -286,7 +286,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft,
 
     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) {
@@ -356,7 +356,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft,
        for (;;) {
            long len;
 
-           if (!fgets (buffer, sizeof(buffer) - 1, in)) {
+           if (!fgets (buffer, sizeof buffer, in)) {
                if (partno == nparts)
                    break;
                adios (NULL, "premature eof");