This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=6d2008502a10248dc0f3b10f6604c7f3b2138b69 commit 6d2008502a10248dc0f3b10f6604c7f3b2138b69 (HEAD -> main) Author: Guillem Jover <[email protected]> AuthorDate: Thu Apr 24 12:44:41 2025 +0200 libcompat: Handle allocation failures in fgetpwent() and fgetgrent() If we fail the allocation while parsing a field, we need to return NULL with errno set to ENOMEM (which should have been done by realloc()). Based-on-patch-by: Simon Richter <[email protected]> --- lib/compat/getent.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/compat/getent.c b/lib/compat/getent.c index e5c55a5f9..4bd655097 100644 --- a/lib/compat/getent.c +++ b/lib/compat/getent.c @@ -158,8 +158,11 @@ fgetpwent(FILE *fp) /* Special case NIS compat entries. */ if (pw.pw_name[0] == '+' || pw.pw_name[0] == '-') { - if (ent_empty_str == NULL) + if (ent_empty_str == NULL) { ent_empty_str = strdup(""); + if (ent_empty_str == NULL) + return NULL; + } pw.pw_passwd = ent_empty_str; pw.pw_uid = 0; @@ -212,11 +215,15 @@ fgetgrent(FILE *fp) gr.gr_passwd = ent_empty_str; gr.gr_gid = 0; gr.gr_mem = alloc_subfields(0, &gr_mem, &gr_mem_len); + if (gr.gr_mem == NULL) + return NULL; gr.gr_mem[0] = NULL; } else { PARSE_FIELD_STR(gr.gr_passwd); PARSE_FIELD_ID(gr.gr_gid); gr.gr_mem = parse_subfields(&cur, ',', &gr_mem, &gr_mem_len); + if (gr.gr_mem == NULL) + return NULL; } return &gr; -- Dpkg.Org's dpkg

