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 <savoptik@altlinux.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
#endif
SYSLOG(LOG_INFO, "add '%s' to shadow group '%s'",
user_name, nsgrp->sg_namp);
#endif
SYSLOG(LOG_INFO, "add '%s' to shadow group '%s'",
user_name, nsgrp->sg_namp);
}
#endif /* SHADOWGRP */
}
}
#endif /* SHADOWGRP */
}