From owner-freebsd-bugs@FreeBSD.ORG Tue Jul 12 16:10:26 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B9C7C16A41C for ; Tue, 12 Jul 2005 16:10:26 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88FDF43D53 for ; Tue, 12 Jul 2005 16:10:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6CGAP2a053904 for ; Tue, 12 Jul 2005 16:10:25 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6CGAPVA053903; Tue, 12 Jul 2005 16:10:25 GMT (envelope-from gnats) Resent-Date: Tue, 12 Jul 2005 16:10:25 GMT Resent-Message-Id: <200507121610.j6CGAPVA053903@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dan Lukes Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D1C6316A41C for ; Tue, 12 Jul 2005 16:07:09 +0000 (GMT) (envelope-from dan@kulesh.obluda.cz) Received: from kulesh.obluda.cz (kulesh.obluda.cz [193.179.22.243]) by mx1.FreeBSD.org (Postfix) with ESMTP id A402943D5C for ; Tue, 12 Jul 2005 16:07:08 +0000 (GMT) (envelope-from dan@kulesh.obluda.cz) Received: from kulesh.obluda.cz (localhost.eunet.cz [127.0.0.1]) by kulesh.obluda.cz (8.13.3/8.13.3) with ESMTP id j6CG6tUG015601 for ; Tue, 12 Jul 2005 18:06:56 +0200 (CEST) (envelope-from dan@kulesh.obluda.cz) Received: (from root@localhost) by kulesh.obluda.cz (8.13.3/8.13.1/Submit) id j6CG6ooF015600; Tue, 12 Jul 2005 18:06:50 +0200 (CEST) (envelope-from dan) Message-Id: <200507121606.j6CG6ooF015600@kulesh.obluda.cz> Date: Tue, 12 Jul 2005 18:06:50 +0200 (CEST) From: Dan Lukes To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/83336: [ PATCH ] libc's parse_ncp() don't check malloc/realloc for failures X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dan Lukes List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jul 2005 16:10:26 -0000 >Number: 83336 >Category: bin >Synopsis: [ PATCH ] libc's parse_ncp() don't check malloc/realloc for failures >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 16:10:25 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 src/lib/libc/rpc/getnetconfig.c,v 1.10 2004/03/05 08:10:17 markm >Description: parse_ncp() called from getnetconfig() and getnetconfigent() dodn't check malloc/realloc for failures. It may cause NULL dereferencing. It assume the allocated memory is '\0' filled also. >How-To-Repeat: >Fix: --- patch begins here --- --- lib/libc/rpc/getnetconfig.c.ORIG Mon Mar 8 14:41:03 2004 +++ lib/libc/rpc/getnetconfig.c Tue Jul 12 17:43:19 2005 @@ -420,18 +420,6 @@ return (NULL); } - if (strcmp(netid, "unix") == 0) { - fprintf(stderr, "The local transport is called \"unix\" "); - fprintf(stderr, "in /etc/netconfig.\n"); - fprintf(stderr, "Please change this to \"local\" manually "); - fprintf(stderr, "or run mergemaster(8).\n"); - fprintf(stderr, "See UPDATING entry 20021216 for details.\n"); - fprintf(stderr, "Continuing in 10 seconds\n\n"); - fprintf(stderr, "This warning will be removed 20030301\n"); - sleep(10); - - } - /* * Look up table if the entries have already been read and parsed in * getnetconfig(), then copy this entry into a buffer and return it. @@ -603,13 +591,18 @@ free(ncp->nc_lookups); /* preallocate one string pointer */ ncp->nc_lookups = (char **)malloc(sizeof (char *)); + if (ncp->nc_lookups == NULL) + return(-1); ncp->nc_nlookups = 0; while ((cp = tokenp) != NULL) { tokenp = _get_next_token(cp, ','); ncp->nc_lookups[(size_t)ncp->nc_nlookups++] = cp; - ncp->nc_lookups = (char **)realloc(ncp->nc_lookups, + ncp->nc_lookups = (char **)reallocf(ncp->nc_lookups, (size_t)(ncp->nc_nlookups+1) *sizeof(char *)); /* for next loop */ + if (ncp->nc_lookups == NULL) + return(-1); } + ncp->nc_lookups[(size_t)ncp->nc_nlookups] = '\0'; } return (0); } --- patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: