Date: Fri, 20 Feb 2015 01:02:33 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279035 - head/lib/libc/gen Message-ID: <201502200102.t1K12X3l014211@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Fri Feb 20 01:02:32 2015 New Revision: 279035 URL: https://svnweb.freebsd.org/changeset/base/279035 Log: Fix small memleaks in nis_passwd() and nis_group(). These only occur upon error. Code Review: https://reviews.freebsd.org/D1849 Reviewed by: delphij CID: 1016715 CID: 1016717 Modified: head/lib/libc/gen/getgrent.c head/lib/libc/gen/getpwent.c Modified: head/lib/libc/gen/getgrent.c ============================================================================== --- head/lib/libc/gen/getgrent.c Fri Feb 20 00:55:38 2015 (r279034) +++ head/lib/libc/gen/getgrent.c Fri Feb 20 01:02:32 2015 (r279035) @@ -1173,8 +1173,10 @@ nis_group(void *retval, void *mdata, va_ * terminator, alignment padding, and one (char *) * pointer for the member list terminator. */ - if (resultlen >= bufsize - _ALIGNBYTES - sizeof(char *)) + if (resultlen >= bufsize - _ALIGNBYTES - sizeof(char *)) { + free(result); goto erange; + } memcpy(buffer, result, resultlen); buffer[resultlen] = '\0'; free(result); Modified: head/lib/libc/gen/getpwent.c ============================================================================== --- head/lib/libc/gen/getpwent.c Fri Feb 20 00:55:38 2015 (r279034) +++ head/lib/libc/gen/getpwent.c Fri Feb 20 01:02:32 2015 (r279035) @@ -1392,8 +1392,10 @@ nis_passwd(void *retval, void *mdata, va continue; } } - if (resultlen >= bufsize) + if (resultlen >= bufsize) { + free(result); goto erange; + } memcpy(buffer, result, resultlen); buffer[resultlen] = '\0'; free(result);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502200102.t1K12X3l014211>