Date: Tue, 12 Jul 2005 21:44:05 +0200 (CEST) From: Dan Lukes <dan@obluda.cz> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/83348: [ PATCH ] Improper handling of malloc failures within libc's yp/xdryp.c Message-ID: <200507121944.j6CJi5m9016904@kulesh.obluda.cz> Resent-Message-ID: <200507121950.j6CJoKG9077709@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 83348 >Category: bin >Synopsis: [ PATCH ] Improper handling of malloc failures within libc's yp/xdryp.c >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jul 12 19:50:19 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Dan Lukes >Release: FreeBSD 5.4-STABLE i386 >Organization: Obludarium >Environment: System: FreeBSD 5.4-STABLE #8: Sat Jul 9 16:31:08 CEST 2005 i386 lib/libc/yp/xdryp.c,v 1.14 2002/04/28 15:18:47 des >Description: Improper handling of malloc failures >How-To-Repeat: >Fix: --- patch begins here --- --- lib/libc/yp/xdryp.c.ORIG Sun Apr 28 17:18:47 2002 +++ lib/libc/yp/xdryp.c Tue Jul 12 21:37:07 2005 @@ -82,10 +82,21 @@ switch (status) { case YP_TRUE: key = (char *)malloc(out.ypresp_all_u.val.key.keydat_len + 1); + if (key == NULL) { + xdr_free((xdrproc_t)xdr_ypresp_all, &out); + *objp = YP_YPERR; + return (FALSE); + } bcopy(out.ypresp_all_u.val.key.keydat_val, key, out.ypresp_all_u.val.key.keydat_len); key[out.ypresp_all_u.val.key.keydat_len] = '\0'; val = (char *)malloc(out.ypresp_all_u.val.val.valdat_len + 1); + if (val == NULL) { + free(key); + xdr_free((xdrproc_t)xdr_ypresp_all, &out); + *objp = YP_YPERR; + return (FALSE); + } bcopy(out.ypresp_all_u.val.val.valdat_val, val, out.ypresp_all_u.val.val.valdat_len); val[out.ypresp_all_u.val.val.valdat_len] = '\0'; --- patch ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507121944.j6CJi5m9016904>