shadow-maint / shadow

Upstream shadow tree
Other
304 stars 232 forks source link

Replace fgetsx() by fgets(3) and fputsx() by fputs(3) #1056

Open alejandro-colomar opened 3 months ago

alejandro-colomar commented 3 months ago

It seems they never worked correctly. Let's keep it simple and remove support for escaped newlines.

Closes: https://github.com/shadow-maint/shadow/issues/1055 Reported-by: @zeha

(Merge after https://github.com/shadow-maint/shadow/pull/1048.)


Revisions:

v1b - Rebase ``` $ git range-diff c76f680fceb4^..gh/fgets string..fgets 1: c76f680f = 1: d0cdc9c8 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 18db7b5a = 2: 4d66df60 lib/, src/: Consistently use NULL with fgets(3) 3: b38c5eb0 = 3: 941c951c lib/, src/: Remove useless casts in fgets(3) 4: 2c112e69 = 4: cd64d530 lib/, po/: Remove fgetsx() and fputsx() ```
v2 - Use getline(3) instead of its pattern. ``` $ git range-diff string gh/fgets fgets 1: d0cdc9c8 = 1: d0cdc9c8 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 4d66df60 = 2: 4d66df60 lib/, src/: Consistently use NULL with fgets(3) 3: 941c951c = 3: 941c951c lib/, src/: Remove useless casts in fgets(3) 4: cd64d530 = 4: cd64d530 lib/, po/: Remove fgetsx() and fputsx() -: -------- > 5: e8036d0e lib/: Use getline(3) instead of its pattern ```
v2b - Remove unused include and macro ``` $ git range-diff string gh/fgets fgets 1: d0cdc9c8 = 1: d0cdc9c8 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 4d66df60 = 2: 4d66df60 lib/, src/: Consistently use NULL with fgets(3) 3: 941c951c = 3: 941c951c lib/, src/: Remove useless casts in fgets(3) 4: cd64d530 = 4: cd64d530 lib/, po/: Remove fgetsx() and fputsx() 5: e8036d0e ! 5: 0c59138d lib/: Use getline(3) instead of its pattern @@ Commit message Signed-off-by: Alejandro Colomar ## lib/commonio.c ## +@@ + #include + + #include "alloc/malloc.h" +-#include "alloc/reallocf.h" + #include "atoi/getnum.h" + #include "commonio.h" + #include "defines.h" +@@ lib/commonio.c: static void add_one_entry_nis (struct commonio_db *db, + } + #endif /* KEEP_NIS_AT_END */ + +-/* Initial buffer size, as well as increment if not sufficient +- (for reading very long lines in group files). */ +-#define BUFLEN 4096 + +-int commonio_open (struct commonio_db *db, int mode) ++int ++commonio_open(struct commonio_db *db, int mode) + { + char *buf; + char *line; @@ lib/commonio.c: int commonio_open (struct commonio_db *db, int mode) return 0; } @@ lib/commonio.c: int commonio_open (struct commonio_db *db, int mode) line = strdup (buf); if (NULL == line) { +@@ lib/commonio.c: int commonio_open (struct commonio_db *db, int mode) + return 0; + } + ++ + /* + * Sort given db according to cmp function (usually compares uids) + */ ## lib/gshadow.c ## @@ lib/gshadow.c: void endsgent (void) ```
v3 - Cosmetic in function declarator. - free(3) memory instead of keeping a static pointer. [@zeha] ``` $ git range-diff string gh/fgets fgets 1: d0cdc9c8 = 1: d0cdc9c8 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 4d66df60 = 2: 4d66df60 lib/, src/: Consistently use NULL with fgets(3) 3: 941c951c = 3: 941c951c lib/, src/: Remove useless casts in fgets(3) 4: cd64d530 = 4: cd64d530 lib/, po/: Remove fgetsx() and fputsx() 5: 0c59138d ! 5: decf456e lib/: Use getline(3) instead of its pattern @@ lib/commonio.c: int commonio_open (struct commonio_db *db, int mode) ## lib/gshadow.c ## @@ lib/gshadow.c: void endsgent (void) + return &sgroup; + } + ++ + /* + * fgetsgent - convert next line in stream to (struct sgrp) + * +@@ lib/gshadow.c: void endsgent (void) + * converts it to a (struct sgrp). NULL is returned on EOF. + */ + +-/*@observer@*//*@null@*/struct sgrp *fgetsgent (/*@null@*/FILE * fp) ++/*@observer@*//*@null@*/struct sgrp * ++fgetsgent(/*@null@*/FILE *fp) + { static size_t buflen = 0; static char *buf = NULL; @@ lib/gshadow.c: void endsgent (void) return (sgetsgent (buf)); } ++ + /* + * getsgent - get a single shadow group entry + */ -: -------- > 6: 3e3b3743 lib/gshadow.c: fgetsgent(): Don't use static variables ```
v3b - Remove formatting fix that complicates diff. ``` $ git range-diff string gh/fgets fgets 1: d0cdc9c8 = 1: d0cdc9c8 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 4d66df60 = 2: 4d66df60 lib/, src/: Consistently use NULL with fgets(3) 3: 941c951c = 3: 941c951c lib/, src/: Remove useless casts in fgets(3) 4: cd64d530 = 4: cd64d530 lib/, po/: Remove fgetsx() and fputsx() 5: decf456e = 5: decf456e lib/: Use getline(3) instead of its pattern 6: 3e3b3743 ! 6: 0936efac lib/gshadow.c: fgetsgent(): Don't use static variables @@ lib/gshadow.c: void endsgent (void) + size_t buflen = 0; + struct sgrp *sg; -- if (NULL == fp) { -+ if (NULL == fp) - return NULL; -- } - - if (getline(&buf, &buflen, fp) == -1) + if (NULL == fp) { return NULL; +@@ lib/gshadow.c: fgetsgent(/*@null@*/FILE *fp) if (stpsep(buf, "\n") == NULL) return NULL; ```
v4 - Globally make the uses of sizeof() consistent. - Provide semantic patches where they can be used to validate the patches, in the corresponding commit message. [@thesamesam ] - Move the white-space and brace changes, to commits where it can be hidden with git-diff(1)'s `-w` and/or `--color-words=.`, so that it doesn't hurt review. ``` $ git range-diff string gh/fgets fgets 1: d0cdc9c8 = 1: d0cdc9c8 lib/gshadow.c: endsgent(): Invert logic to reduce indentation -: -------- > 2: 8f77030f contrib/, lib/, src/: Consistently use sizeof() as if it were a function 3: 941c951c ! 3: b2b9bbb3 lib/, src/: Remove useless casts in fgets(3) @@ Metadata ## Commit message ## lib/, src/: Remove useless casts in fgets(3) + This patch can be replicated with the following semantic patch: + + $ cat fgets_cast.sp + @@ + expression a, b, c; + @@ + + - fgets(a, (int) (b), c) + + fgets(a, b, c) + + @@ + expression a, b, c; + @@ + + - fgets(a, (int) b, c) + + fgets(a, b, c) + + @@ + expression a, b, c; + @@ + + - fgetsx(a, (int) (b), c) + + fgetsx(a, b, c) + + @@ + expression a, b, c; + @@ + + - fgetsx(a, (int) b, c) + + fgetsx(a, b, c) + + @@ + expression a, b, c, p; + @@ + + - p->fgets(a, (int) (b), c) + + p->fgets(a, b, c) + + @@ + expression a, b, c, p; + @@ + + - p->fgets(a, (int) b, c) + + p->fgets(a, b, c) + + which is applied as: + + $ find lib* src/ -type f \ + | xargs spatch --sp-file ~/tmp/spatch/fgets_cast.sp --in-place; + Signed-off-by: Alejandro Colomar ## lib/commonio.c ## @@ lib/commonio.c: int commonio_open (struct commonio_db *db, int mode) - if (db->ops->fgets (buf + len, - (int) (buflen - len), - db->fp) == NULL) { -+ if (db->ops->fgets(buf + len, buflen - len, db->fp) == NULL) ++ if (db->ops->fgets(buf + len, buflen - len, db->fp) == NULL) { goto cleanup_buf; -- } + } } - stpsep(buf, "\n"); - ## lib/gshadow.c ## @@ lib/gshadow.c: void endsgent (void) buflen *= 2; len = strlen (buf); -- if (fgetsx(&buf[len], (int) (buflen - len), fp) == NULL) -+ if (fgetsx(&buf[len], buflen - len, fp) == NULL) +- if (fgetsx (&buf[len], +- (int) (buflen - len), +- fp) != &buf[len]) { ++ if (fgetsx(&buf[len], buflen - len, fp) != &buf[len]) { return NULL; + } } - stpsep(buf, "\n"); ## lib/setupenv.c ## @@ lib/setupenv.c: static void read_env_file (const char *filename) if (NULL == fp) { return; } -- while (fgets(buf, (int)(sizeof(buf)), fp) != NULL) { -+ while (fgets(buf, sizeof(buf), fp) != NULL) { +- while (fgets(buf, (int) sizeof(buf), fp) == buf) { ++ while (fgets(buf, sizeof(buf), fp) == buf) { if (stpsep(buf, "\n") == NULL) break; @@ src/chgpasswd.c: int main (int argc, char **argv) * group entry for each group will be looked up in the appropriate * file (gshadow or group) and the password changed. */ -- while (fgets (buf, (int) sizeof buf, stdin) != NULL) { +- while (fgets(buf, (int) sizeof(buf), stdin) != NULL) { + while (fgets(buf, sizeof(buf), stdin) != NULL) { line++; if (stpsep(buf, "\n") == NULL) { 2: 4d66df60 ! 4: 00db7341 lib/, src/: Consistently use NULL with fgets(3) @@ Commit message is the header that provides NULL; add it where appropriate. + The meat of this patch can be approximated with the following semantic + patch: + + $ cat ~/tmp/spatch/fgets_null.sp + @@ + expression a, b, c; + @@ + + - fgets(a, b, c) == a + + fgets(a, b, c) != NULL + + @@ + expression a, b, c; + @@ + + - fgetsx(a, b, c) == a + + fgetsx(a, b, c) != NULL + + @@ + expression a, b, c, p; + @@ + + - p->fgets(a, b, c) == a + + p->fgets(a, b, c) != NULL + + @@ + expression a, b, c; + @@ + + - fgets(a, b, c) != a + + fgets(a, b, c) == NULL + + @@ + expression a, b, c; + @@ + + - fgetsx(a, b, c) != a + + fgetsx(a, b, c) == NULL + + @@ + expression a, b, c, p; + @@ + + - p->fgets(a, b, c) != a + + p->fgets(a, b, c) == NUL + + Applied as + + $ find contrib/ lib* src/ -type f \ + | xargs spatch --sp-file ~/tmp/spatch/fgets_null.sp --in-place; + + The differences between the actual patch and the approximation via the + semantic patch from above are includes, whitespace, braces, and a case + where there was an implicit pointer-to-bool comparison which I made + explicit. When reviewing, it'll be useful to use git-diff(1) with '-w' + and '--color-words=.'. + Signed-off-by: Alejandro Colomar ## lib/commonio.c ## @@ lib/gshadow.c: void endsgent (void) buflen *= 2; len = strlen (buf); -- if (fgetsx (&buf[len], -- (int) (buflen - len), -- fp) != &buf[len]) { -+ if (fgetsx(&buf[len], (int) (buflen - len), fp) == NULL) +- if (fgetsx(&buf[len], buflen - len, fp) != &buf[len]) { ++ if (fgetsx(&buf[len], buflen - len, fp) == NULL) return NULL; - } } @@ lib/hushed.c: bool hushed (const char *username) if (NULL == fp) { return false; } -- for (found = false; !found && (fgets (buf, sizeof buf, fp) == buf);) { +- for (found = false; !found && (fgets(buf, sizeof(buf), fp) == buf);) { + for (found = false; !found && (fgets(buf, sizeof(buf), fp) != NULL);) { stpsep(buf, "\n"); found = (strcmp (buf, pw->pw_shell) == 0) || @@ lib/loginprompt.c: login_prompt(char *name, int namesize) */ MEMZERO(buf); -- if (fgets (buf, sizeof buf, stdin) != buf) { +- if (fgets(buf, sizeof(buf), stdin) != buf) { + if (fgets(buf, sizeof(buf), stdin) == NULL) exit (EXIT_FAILURE); - } @@ lib/setupenv.c: static void read_env_file (const char *filename) if (NULL == fp) { return; } -- while (fgets (buf, (int)(sizeof buf), fp) == buf) { -+ while (fgets(buf, (int)(sizeof(buf)), fp) != NULL) { +- while (fgets(buf, sizeof(buf), fp) == buf) { ++ while (fgets(buf, sizeof(buf), fp) != NULL) { if (stpsep(buf, "\n") == NULL) break; @@ lib/ttytype.c: void ttytype (const char *line) perror (typefile); return; } -- while (fgets (buf, sizeof buf, fp) == buf) { +- while (fgets(buf, sizeof(buf), fp) == buf) { + while (fgets(buf, sizeof(buf), fp) != NULL) { if (buf[0] == '#') { continue; } + ## lib/user_busy.c ## +@@ + #ident "$Id: $" + + #include ++#include + #include + #include + #include +@@ lib/user_busy.c: static int check_status (const char *name, const char *sname, uid_t uid) + if (NULL == sfile) { + return 0; + } +- while (fgets(line, sizeof(line), sfile) == line) { ++ while (fgets(line, sizeof(line), sfile) != NULL) { + if (strncmp (line, "Uid:\t", 5) == 0) { + unsigned long ruid, euid, suid; + + ## src/login_nopam.c ## @@ src/login_nopam.c: login_access(const char *user, const char *from) if (NULL != fp) { int lineno = 0; /* for diagnostics */ while ( !match -- && (fgets (line, sizeof (line), fp) == line)) +- && (fgets(line, sizeof(line), fp) == line)) + && (fgets(line, sizeof(line), fp) != NULL)) { char *p; @@ src/useradd.c: get_defaults(void) * Read the file a line at a time. Only the lines that have relevant * values are used, everything else can be ignored. */ -- while (fgets (buf, sizeof buf, fp) == buf) { +- while (fgets(buf, sizeof(buf), fp) == buf) { + while (fgets(buf, sizeof(buf), fp) != NULL) { stpsep(buf, "\n"); @@ src/useradd.c: set_defaults(void) goto skip; } -- while (fgets (buf, sizeof buf, ifp) == buf) { +- while (fgets(buf, sizeof(buf), ifp) == buf) { + while (fgets(buf, sizeof(buf), ifp) != NULL) { char *val; 4: cd64d530 ! 5: c1ccbb9a lib/, po/: Remove fgetsx() and fputsx() @@ lib/commonio.c: int commonio_open (struct commonio_db *db, int mode) goto cleanup_errno; len = strlen (buf); -- if (db->ops->fgets(buf + len, buflen - len, db->fp) == NULL) +- if (db->ops->fgets(buf + len, buflen - len, db->fp) == NULL) { + if (fgets(buf + len, buflen - len, db->fp) == NULL) goto cleanup_buf; +- } } stpsep(buf, "\n"); + @@ lib/commonio.c: static int write_all (const struct commonio_db *db) return -1; } } else if (NULL != p->line) { - if (db->ops->fputs (p->line, db->fp) == EOF) { -+ if (fputs(p->line, db->fp) == EOF) { ++ if (fputs(p->line, db->fp) == EOF) + return -1; +- } ++ + if (putc ('\n', db->fp) == EOF) { return -1; } - if (putc ('\n', db->fp) == EOF) { ## lib/commonio.h ## @@ lib/commonio.h: struct commonio_ops { 5: decf456e = 6: 9991189d lib/: Use getline(3) instead of its pattern 6: 0936efac = 7: 51005793 lib/gshadow.c: fgetsgent(): Don't use static variables ```
v4b - Rebase ``` $ git range-diff d0cdc9c8f683^..gh/fgets string..fgets 1: d0cdc9c8 = 1: 8dbc8149 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 8f77030f ! 2: ac57816a contrib/, lib/, src/: Consistently use sizeof() as if it were a function @@ Commit message Signed-off-by: Alejandro Colomar ## contrib/adduser.c ## -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) printf ("\nLogin to add (^C to quit): "); fflush (stdout); @@ contrib/adduser.c: main(void) if (!strlen (usrname)) { -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) printf ("\nFull Name [%s]: ", usrname); fflush (stdout); @@ contrib/adduser.c: main(void) strcpy (person, usrname); }; -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) bad = 0; printf ("GID [%d]: ", DEFAULT_GROUP); fflush (stdout); @@ contrib/adduser.c: main(void) if (!strlen (foo)) group = DEFAULT_GROUP; else if (isdigit (*foo)) -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) printf ("\nIf home dir ends with a / then '%s' will be appended to it\n", usrname); printf ("Home Directory [%s/%s]: ", DEFAULT_HOME, usrname); fflush (stdout); @@ contrib/adduser.c: main(void) if (!strlen(dir)) /* hit return */ sprintf(dir, "%s/%s", DEFAULT_HOME, usrname); else if (dir[strlen (dir) - 1] == '/') -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) printf ("\nShell [%s]: ", DEFAULT_SHELL); fflush (stdout); @@ contrib/adduser.c: main(void) if (!strlen (shell)) strcpy(shell, DEFAULT_SHELL); else -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) #endif printf ("\nMin. Password Change Days [%d]: ", DEFAULT_MIN_PASS); fflush (stdout); @@ contrib/adduser.c: main(void) if (strlen (foo) > 1) min_pass = DEFAULT_MIN_PASS; else -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) printf ("Max. Password Change Days [%d]: ", DEFAULT_MAX_PASS); fflush (stdout); @@ contrib/adduser.c: main(void) if (strlen (foo) > 1) max_pass = atoi (foo); else -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) printf ("Password Warning Days [%d]: ", DEFAULT_WARN_PASS); fflush (stdout); @@ contrib/adduser.c: main(void) warn_pass = atoi (foo); if (warn_pass == 0) -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) printf ("Days after Password Expiry for Account Locking [%d]: ", DEFAULT_USER_DIE); fflush (stdout); @@ contrib/adduser.c: main(void) user_die = atoi (foo); if (user_die == 0) user_die = DEFAULT_USER_DIE; -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) min_pass, max_pass, warn_pass, user_die); printf ("\nIs this correct? [y/N]: "); fflush (stdout); - safeget (foo, sizeof (foo)); + safeget(foo, sizeof(foo)); - done = bad = correct = !!strchr("yY", foo[0]); + done = bad = correct = (foo[0] == 'y' || foo[0] == 'Y'); -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) *environ = NULL; @@ contrib/adduser.c: main(void) sprintf (cmd, "%s -g %d -d %s -s %s -c \"%s\" -m -k /etc/skel %s", USERADD_PATH, group, dir, shell, person, usrname); printf ("Calling useradd to add new user:\n%s\n", cmd); -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) */ setuid (0); @@ contrib/adduser.c: main(void) /* Chage runs suid root. => we need ruid root to run it with * anything other than chage -l -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) /* I want to add a user completely with one easy command --chris */ #ifdef HAVE_QUOTAS @@ contrib/adduser.c: main(void) sprintf (cmd, "%s -p %s -u %s", EDQUOTA_PATH, QUOTA_DEFAULT, usrname); printf ("%s\n", cmd); if (system (cmd)) -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) printf ("\nDefault quota set.\n"); #endif /* HAVE_QUOTAS */ @@ contrib/adduser.c: main(void) sprintf (cmd, "%s %s", PASSWD_PATH, usrname); if (system (cmd)) { -@@ contrib/adduser.c: main(void) +@@ contrib/adduser.c: main (void) #endif } #ifdef IMMEDIATE_CHANGE @@ src/lastlog.c: static void update_one (/*@null@*/const struct passwd *pw) Prog, (unsigned long)pw->pw_uid); ## src/login.c ## -@@ src/login.c: main(int argc, char **argv) +@@ src/login.c: int main (int argc, char **argv) unsigned int failcount = 0; /* Make the login prompt look like we want it */ @@ src/login.c: main(int argc, char **argv) SNPRINTF(loginprompt, _("%s login: "), hostn); } else { STRTCPY(loginprompt, _("login: ")); -@@ src/login.c: main(int argc, char **argv) +@@ src/login.c: int main (int argc, char **argv) #ifdef HAVE_LL_HOST /* __linux__ || SUN4 */ if ('\0' != ll.ll_host[0]) { printf (_(" from %.*s"), 3: b2b9bbb3 = 3: 9fdffc48 lib/, src/: Remove useless casts in fgets(3) 4: 00db7341 = 4: d46fd02e lib/, src/: Consistently use NULL with fgets(3) 5: c1ccbb9a = 5: 1721920a lib/, po/: Remove fgetsx() and fputsx() 6: 9991189d = 6: 664817b3 lib/: Use getline(3) instead of its pattern 7: 51005793 = 7: a71fc6f3 lib/gshadow.c: fgetsgent(): Don't use static variables ```
v4c - Rebase ``` $ git range-diff gh/string..gh/fgets string..fgets 1: 8dbc8149 = 1: 8af482a6 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: ac57816a = 2: 7cae4284 contrib/, lib/, src/: Consistently use sizeof() as if it were a function 3: 9fdffc48 = 3: 410f2492 lib/, src/: Remove useless casts in fgets(3) 4: d46fd02e = 4: a0953493 lib/, src/: Consistently use NULL with fgets(3) 5: 1721920a = 5: 9abcea85 lib/, po/: Remove fgetsx() and fputsx() 6: 664817b3 = 6: dc3819ff lib/: Use getline(3) instead of its pattern 7: a71fc6f3 = 7: e49bcf8b lib/gshadow.c: fgetsgent(): Don't use static variables ```
v4d - Rebase ``` $ git range-diff gh/string..gh/fgets string..fgets 1: 8af482a6 = 1: b4a37bc9 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 7cae4284 = 2: d1abe1ac contrib/, lib/, src/: Consistently use sizeof() as if it were a function 3: 410f2492 = 3: f388b921 lib/, src/: Remove useless casts in fgets(3) 4: a0953493 = 4: 31c6c72f lib/, src/: Consistently use NULL with fgets(3) 5: 9abcea85 = 5: bf0a81e6 lib/, po/: Remove fgetsx() and fputsx() 6: dc3819ff = 6: bbbae6af lib/: Use getline(3) instead of its pattern 7: e49bcf8b = 7: f7d5cc12 lib/gshadow.c: fgetsgent(): Don't use static variables ```
v4e - Rebase ``` $ git range-diff gh/string..gh/fgets string..fgets 1: b4a37bc9 = 1: be73a591 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: d1abe1ac = 2: 219af975 contrib/, lib/, src/: Consistently use sizeof() as if it were a function 3: f388b921 = 3: 691673bc lib/, src/: Remove useless casts in fgets(3) 4: 31c6c72f = 4: 7cb79af6 lib/, src/: Consistently use NULL with fgets(3) 5: bf0a81e6 = 5: 364b354d lib/, po/: Remove fgetsx() and fputsx() 6: bbbae6af = 6: 3f398748 lib/: Use getline(3) instead of its pattern 7: f7d5cc12 = 7: ef91817e lib/gshadow.c: fgetsgent(): Don't use static variables ```
v4f - Rebase ``` $ git range-diff gh/string..gh/fgets string..fgets 1: be73a591 = 1: 5684988b lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 219af975 = 2: 022f2da0 contrib/, lib/, src/: Consistently use sizeof() as if it were a function 3: 691673bc = 3: 05fe7f89 lib/, src/: Remove useless casts in fgets(3) 4: 7cb79af6 = 4: 5991bd9c lib/, src/: Consistently use NULL with fgets(3) 5: 364b354d = 5: 5cf10040 lib/, po/: Remove fgetsx() and fputsx() 6: 3f398748 = 6: 7e3d5d58 lib/: Use getline(3) instead of its pattern 7: ef91817e = 7: 27dd9f5c lib/gshadow.c: fgetsgent(): Don't use static variables ```
v4g - Rebase ``` $ git range-diff 5684988b^..gh/fgets string..fgets 1: 5684988b = 1: 77e6a686 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 022f2da0 = 2: c42d9568 contrib/, lib/, src/: Consistently use sizeof() as if it were a function 3: 05fe7f89 = 3: b67527a6 lib/, src/: Remove useless casts in fgets(3) 4: 5991bd9c = 4: 87af89d8 lib/, src/: Consistently use NULL with fgets(3) 5: 5cf10040 = 5: 375d57a0 lib/, po/: Remove fgetsx() and fputsx() 6: 7e3d5d58 = 6: d094dc5d lib/: Use getline(3) instead of its pattern 7: 27dd9f5c = 7: 8ef8fc73 lib/gshadow.c: fgetsgent(): Don't use static variables ```
v4h - Rebase ``` $ git range-diff gh/string..gh/fgets string..fgets 1: 77e6a686 = 1: 8a8c6635 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: c42d9568 ! 2: da61e23a contrib/, lib/, src/: Consistently use sizeof() as if it were a function @@ lib/tz.c if ( (NULL == fp) - || (fgets (tzbuf, sizeof (tzbuf), fp) == NULL)) { + || (fgets(tzbuf, sizeof(tzbuf), fp) == NULL)) { - def_tz = getdef_str ("ENV_TZ"); - if ((NULL == def_tz) || ('/' == def_tz[0])) { - def_tz = "TZ=CST6CDT"; + result = "TZ=CST6CDT"; + } else { + stpsep(tzbuf, "\n"); ## lib/user_busy.c ## @@ lib/user_busy.c: user_busy_utmp(const char *name) @@ src/useradd.c: static void lastlog_reset (uid_t uid) return; } if ( (lseek (fd, offset_uid, SEEK_SET) != offset_uid) -- || (write_full (fd, &ll, sizeof (ll)) != (ssize_t) sizeof (ll)) -+ || (write_full(fd, &ll, sizeof(ll)) != (ssize_t) sizeof(ll)) +- || (write_full (fd, &ll, sizeof (ll)) == -1) ++ || (write_full(fd, &ll, sizeof(ll)) == -1) || (fsync (fd) != 0)) { fprintf (stderr, _("%s: failed to reset the lastlog entry of UID %lu: %s\n"), 3: b67527a6 = 3: 9f934b2a lib/, src/: Remove useless casts in fgets(3) 4: 87af89d8 = 4: 8a8620eb lib/, src/: Consistently use NULL with fgets(3) 5: 375d57a0 = 5: 2e696e77 lib/, po/: Remove fgetsx() and fputsx() 6: d094dc5d = 6: 2375cbfc lib/: Use getline(3) instead of its pattern 7: 8ef8fc73 = 7: 7d2a356c lib/gshadow.c: fgetsgent(): Don't use static variables ```
v4i - Rebase ``` $ git range-diff gh/string..gh/fgets string..fgets 1: 8a8c6635 = 1: c6dabf04 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: da61e23a = 2: 6d57727a contrib/, lib/, src/: Consistently use sizeof() as if it were a function 3: 9f934b2a = 3: 857da077 lib/, src/: Remove useless casts in fgets(3) 4: 8a8620eb = 4: db2b027d lib/, src/: Consistently use NULL with fgets(3) 5: 2e696e77 = 5: c8645b33 lib/, po/: Remove fgetsx() and fputsx() 6: 2375cbfc = 6: 8d9b55dd lib/: Use getline(3) instead of its pattern 7: 7d2a356c = 7: b5663560 lib/gshadow.c: fgetsgent(): Don't use static variables ```
v4j - Rebase ``` $ git range-diff gh/string..gh/fgets string..fgets 1: c6dabf04 = 1: 2ff6e318 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 6d57727a = 2: 6faa0944 contrib/, lib/, src/: Consistently use sizeof() as if it were a function 3: 857da077 = 3: ee315ddc lib/, src/: Remove useless casts in fgets(3) 4: db2b027d = 4: 876c36d1 lib/, src/: Consistently use NULL with fgets(3) 5: c8645b33 = 5: 5fc868e2 lib/, po/: Remove fgetsx() and fputsx() 6: 8d9b55dd = 6: f7ac2b0a lib/: Use getline(3) instead of its pattern 7: b5663560 = 7: 9fd4a0b3 lib/gshadow.c: fgetsgent(): Don't use static variables ```
v4k - Rebase ``` $ git range-diff gh/string..gh/fgets string..fgets 1: 2ff6e318 = 1: 2b6a1413 lib/gshadow.c: endsgent(): Invert logic to reduce indentation 2: 6faa0944 ! 2: 61bc9a04 contrib/, lib/, src/: Consistently use sizeof() as if it were a function @@ lib/log.c: void dolastlog ( ## lib/loginprompt.c ## -@@ lib/loginprompt.c: login_prompt(char *name, int namesize) +@@ lib/loginprompt.c: void login_prompt (char *name, int namesize) (void) fclose (fp); } } @@ lib/loginprompt.c: login_prompt(char *name, int namesize) printf (_("\n%s login: "), buf); (void) fflush (stdout); -@@ lib/loginprompt.c: login_prompt(char *name, int namesize) +@@ lib/loginprompt.c: void login_prompt (char *name, int namesize) */ MEMZERO(buf); 3: ee315ddc = 3: ca165ccf lib/, src/: Remove useless casts in fgets(3) 4: 876c36d1 ! 4: 8929e11e lib/, src/: Consistently use NULL with fgets(3) @@ lib/loginprompt.c #include "attr.h" #include "defines.h" -@@ lib/loginprompt.c: login_prompt(char *name, int namesize) +@@ lib/loginprompt.c: void login_prompt (char *name, int namesize) */ MEMZERO(buf); 5: 5fc868e2 = 5: fee111ca lib/, po/: Remove fgetsx() and fputsx() 6: f7ac2b0a = 6: 08d1534f lib/: Use getline(3) instead of its pattern 7: 9fd4a0b3 = 7: b6b6a6b5 lib/gshadow.c: fgetsgent(): Don't use static variables ```
thesamesam commented 3 months ago

I really feel this PR is still pretty noisy.