From: Artem Semenov Date: Mon, 8 Jun 2026 12:34:35 +0000 (+0300) Subject: fix: memory leak of nsgrp in src/useradd.c grp_update() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;p=thirdparty%2Fshadow.git fix: memory leak of nsgrp in src/useradd.c grp_update() grp_update() also duplicates each shadow group with __sgr_dup() and never frees the 'nsgrp' copy. Release it with sgr_free(). valgrind --leak-check=full --show-leak-kinds=all \ src/useradd -M -N -G grp1,...,grp10 alice, before this commit: 691 (320 direct, 371 indirect) bytes in 10 blocks are definitely lost at 0x4848EB8: calloc by __sgr_dup (sgroupio.c:37) by grp_update (useradd.c:1104) definitely lost: 480 bytes in 30 blocks after this commit: definitely lost: 160 bytes in 20 blocks Signed-off-by: Artem Semenov Reviewed-by: Alejandro Colomar --- diff --git a/src/useradd.c b/src/useradd.c index e243c6857..25b7f4f3c 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -1125,6 +1125,7 @@ static void grp_update (bool process_selinux) #endif SYSLOG(LOG_INFO, "add '%s' to shadow group '%s'", user_name, nsgrp->sg_namp); + sgr_free (nsgrp); } #endif /* SHADOWGRP */ }