From: Alejandro Colomar Date: Sun, 21 Jul 2024 16:40:25 +0000 (+0200) Subject: lib/, po/: Remove fgetsx() and fputsx() X-Git-Tag: 4.19.0-rc1~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b0a7ce58b924b04101a3a19f9f28673f578d7cce;p=thirdparty%2Fshadow.git lib/, po/: Remove fgetsx() and fputsx() It seems they never worked correctly. Let's keep it simple and remove support for escaped newlines. Closes: Reported-by: Chris Hofstaedtler Signed-off-by: Alejandro Colomar --- diff --git a/lib/Makefile.am b/lib/Makefile.am index 798262500..c402ff02a 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -83,7 +83,6 @@ libshadow_la_SOURCES = \ find_new_uid.c \ find_new_sub_gids.c \ find_new_sub_uids.c \ - fputsx.c \ fs/mkstemp/fmkomstemp.c \ fs/mkstemp/fmkomstemp.h \ fs/mkstemp/mkomstemp.c \ diff --git a/lib/commonio.c b/lib/commonio.c index 7cb2f420a..cd18560f6 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -639,7 +639,7 @@ int commonio_open (struct commonio_db *db, int mode) if (NULL == buf) goto cleanup_errno; - while (db->ops->cio_fgets(buf, buflen, db->fp) != NULL) { + while (fgets(buf, buflen, db->fp) != NULL) { struct commonio_entry *p; while ( (strrchr (buf, '\n') == NULL) @@ -652,7 +652,7 @@ int commonio_open (struct commonio_db *db, int mode) goto cleanup_errno; len = strlen (buf); - if (db->ops->cio_fgets(buf + len, buflen - len, db->fp) == NULL) + if (fgets(buf + len, buflen - len, db->fp) == NULL) goto cleanup_buf; } stpsep(buf, "\n"); @@ -870,7 +870,7 @@ static int write_all (const struct commonio_db *db) return -1; } } else if (NULL != p->line) { - if (db->ops->cio_fputs(p->line, db->fp) == EOF) + if (fputs(p->line, db->fp) == EOF) return -1; if (putc ('\n', db->fp) == EOF) { diff --git a/lib/commonio.h b/lib/commonio.h index 1f32facea..2e86d561d 100644 --- a/lib/commonio.h +++ b/lib/commonio.h @@ -60,15 +60,6 @@ struct commonio_ops { */ int (*cio_put)(const void *, FILE *); - /* - * fgets and fputs (can be replaced by versions that - * understand line continuation conventions). - */ - ATTR_ACCESS(write_only, 1, 2) - /*@null@*/char *(*cio_fgets)(/*@returned@*/char *restrict s, int n, - FILE *restrict stream); - int (*cio_fputs)(const char *, FILE *); - /* * open_hook and close_hook. * If non NULL, these functions will be called after the database diff --git a/lib/fputsx.c b/lib/fputsx.c deleted file mode 100644 index 0f86da4f3..000000000 --- a/lib/fputsx.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh - * SPDX-FileCopyrightText: 1996 - 1999, Marek Michałkiewicz - * SPDX-FileCopyrightText: 2005 , Tomasz Kłoczko - * SPDX-FileCopyrightText: 2008 , Nicolas François - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "config.h" - -#include -#include -#include - -#include "defines.h" -#include "prototypes.h" -#include "string/strcmp/streq.h" - - -/*@null@*/char * -fgetsx(/*@returned@*/char *restrict buf, int cnt, FILE *restrict f) -{ - char *cp = buf; - char *ep; - - while (cnt > 0) { - if (fgets(cp, cnt, f) == NULL) { - if (cp == buf) { - return NULL; - } else { - break; - } - } - ep = strrchr (cp, '\\'); - if ((NULL != ep) && (*(ep + 1) == '\n')) { - cnt -= ep - cp; - if (cnt > 0) - cp = stpcpy(ep, ""); - } else { - break; - } - } - return buf; -} - -int fputsx (const char *s, FILE * stream) -{ - int i; - - for (i = 0; !streq(s, ""); i++, s++) { - if (putc (*s, stream) == EOF) { - return EOF; - } - -#if 0 /* The standard getgr*() can't handle that. --marekm */ - if (i > (BUFSIZ / 2)) { - if (putc ('\\', stream) == EOF || - putc ('\n', stream) == EOF) - return EOF; - - i = 0; - } -#endif - } - return 0; -} - diff --git a/lib/groupio.c b/lib/groupio.c index b9ef52854..a28e96c59 100644 --- a/lib/groupio.c +++ b/lib/groupio.c @@ -102,8 +102,6 @@ static struct commonio_ops group_ops = { group_getname, group_parse, group_put, - fgetsx, - fputsx, group_open_hook, group_close_hook }; diff --git a/lib/prototypes.h b/lib/prototypes.h index 0a951f880..d1fb9b878 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -155,11 +155,6 @@ extern int getrange (const char *range, /* gettime.c */ extern time_t gettime (void); -/* fputsx.c */ -ATTR_ACCESS(write_only, 1, 2) -extern /*@null@*/char *fgetsx(/*@returned@*/char *restrict, int, FILE *restrict); -extern int fputsx (const char *, FILE *); - /* groupio.c */ extern void __gr_del_entry (const struct commonio_entry *ent); extern /*@observer@*/const struct commonio_db *__gr_get_db (void); diff --git a/lib/pwio.c b/lib/pwio.c index f4044c9b1..57ed4a452 100644 --- a/lib/pwio.c +++ b/lib/pwio.c @@ -75,8 +75,6 @@ static struct commonio_ops passwd_ops = { passwd_getname, passwd_parse, passwd_put, - fgets, - fputs, NULL, /* open_hook */ NULL /* close_hook */ }; diff --git a/lib/sgroupio.c b/lib/sgroupio.c index ef6fb4d59..5df3ffc71 100644 --- a/lib/sgroupio.c +++ b/lib/sgroupio.c @@ -202,8 +202,6 @@ static struct commonio_ops gshadow_ops = { gshadow_getname, gshadow_parse, gshadow_put, - fgetsx, - fputsx, NULL, /* open_hook */ NULL /* close_hook */ }; diff --git a/lib/shadow/gshadow/fgetsgent.c b/lib/shadow/gshadow/fgetsgent.c index 64e7d4541..91cc52000 100644 --- a/lib/shadow/gshadow/fgetsgent.c +++ b/lib/shadow/gshadow/fgetsgent.c @@ -51,7 +51,7 @@ fgetsgent(FILE *fp) return NULL; } - if (fgetsx(buf, buflen, fp) == NULL) + if (fgets(buf, buflen, fp) == NULL) return NULL; while ( (strrchr(buf, '\n') == NULL) @@ -66,7 +66,7 @@ fgetsgent(FILE *fp) buflen *= 2; len = strlen (buf); - if (fgetsx(&buf[len], buflen - len, fp) == NULL) + if (fgets(&buf[len], buflen - len, fp) == NULL) return NULL; } stpsep(buf, "\n"); diff --git a/lib/shadow/gshadow/putsgent.c b/lib/shadow/gshadow/putsgent.c index cd8dc024b..488f4a0e4 100644 --- a/lib/shadow/gshadow/putsgent.c +++ b/lib/shadow/gshadow/putsgent.c @@ -84,11 +84,7 @@ putsgent(const struct sgrp *sgrp, FILE *fp) } stpcpy(cp, "\n"); - /* - * Output using the function which understands the line - * continuation conventions. - */ - if (fputsx (buf, fp) == EOF) { + if (fputs(buf, fp) == EOF) { free (buf); return -1; } diff --git a/lib/shadowio.c b/lib/shadowio.c index 4d2bf3b7f..bf875036e 100644 --- a/lib/shadowio.c +++ b/lib/shadowio.c @@ -76,8 +76,6 @@ static struct commonio_ops shadow_ops = { shadow_getname, shadow_parse, shadow_put, - fgets, - fputs, NULL, /* open_hook */ NULL /* close_hook */ }; diff --git a/lib/subordinateio.c b/lib/subordinateio.c index 7aa912d00..f9a845ddf 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -138,8 +138,6 @@ static struct commonio_ops subordinate_ops = { NULL, /* getname */ subordinate_parse, /* parse */ subordinate_put, /* put */ - fgets, /* fgets */ - fputs, /* fputs */ NULL, /* open_hook */ NULL, /* close_hook */ }; diff --git a/po/POTFILES.in b/po/POTFILES.in index 376dec4e1..8d8ae28a4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -21,7 +21,6 @@ lib/find_new_gid.c lib/find_new_sub_gids.c lib/find_new_sub_uids.c lib/find_new_uid.c -lib/fputsx.c lib/getdef.c lib/getgr_nam_gid.c lib/getrange.c