From: Alejandro Colomar Date: Sun, 12 May 2024 23:18:48 +0000 (+0200) Subject: lib/: Use REALLOCF() instead of its pattern X-Git-Tag: 4.17.0-rc1~195 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d611d1a9479a57e21db2f062e175a05899a378df;p=thirdparty%2Fshadow.git lib/: Use REALLOCF() instead of its pattern Signed-off-by: Alejandro Colomar --- diff --git a/lib/commonio.c b/lib/commonio.c index aa6d8c872..1a6f1db5b 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -648,11 +648,10 @@ int commonio_open (struct commonio_db *db, int mode) size_t len; buflen += BUFLEN; - cp = REALLOC(buf, buflen, char); - if (NULL == cp) { - goto cleanup_buf; + buf = REALLOCF(buf, buflen, char); + if (NULL == buf) { + goto cleanup_ENOMEM; } - buf = cp; len = strlen (buf); if (db->ops->fgets (buf + len, (int) (buflen - len), diff --git a/lib/subordinateio.c b/lib/subordinateio.c index a4e114de3..9dd7702ab 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -929,9 +929,8 @@ static bool all_digits(const char *str) static int append_uids(uid_t **uids, const char *owner, int n) { - uid_t owner_uid; - uid_t *ret; - int i; + int i; + uid_t owner_uid; if (all_digits(owner)) { i = sscanf(owner, "%d", &owner_uid); @@ -957,13 +956,11 @@ static int append_uids(uid_t **uids, const char *owner, int n) return n; } - ret = REALLOC(*uids, n + 1, uid_t); - if (!ret) { - free(*uids); + *uids = REALLOCF(*uids, n + 1, uid_t); + if (!*uids) return -1; - } - ret[n] = owner_uid; - *uids = ret; + + (*uids)[n] = owner_uid; return n+1; }