From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 841 invoked by alias); 16 Sep 2010 17:26:35 -0000 Received: (qmail 828 invoked by uid 22791); 16 Sep 2010 17:26:35 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-pw0-f41.google.com (HELO mail-pw0-f41.google.com) (209.85.160.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 16 Sep 2010 17:26:29 +0000 Received: by pwj6 with SMTP id 6so1166058pwj.0 for ; Thu, 16 Sep 2010 10:26:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.12.3 with SMTP id 3mr3112860wfl.187.1284657988110; Thu, 16 Sep 2010 10:26:28 -0700 (PDT) Received: by 10.220.186.4 with HTTP; Thu, 16 Sep 2010 10:26:27 -0700 (PDT) Date: Thu, 16 Sep 2010 18:30:00 -0000 Message-ID: Subject: [patch] [trivial] fix NULL deref From: Ali Lakhia To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00302.txt.bz2 Please see patch to fix NULL dereference in strchr() function. Thanks. -Ali --- gdb-7.1/gdb/fork-child.c 2009-12-31 23:31:31.000000000 -0800 +++ gdb-7.1/gdb/fork-child.c 2010-09-16 10:17:25.000000000 -0700 @@ -52,7 +52,7 @@ static void breakup_args (char *scratch, char **argv) { - char *cp = scratch; + char *cp = scratch, *tmp; for (;;) { @@ -68,15 +68,16 @@ *argv++ = cp; /* Scan for next arg separator. */ - cp = strchr (cp, ' '); - if (cp == NULL) - cp = strchr (cp, '\t'); - if (cp == NULL) - cp = strchr (cp, '\n'); + tmp = strchr (cp, ' '); + if (tmp == NULL) + tmp = strchr (cp, '\t'); + if (tmp == NULL) + tmp = strchr (cp, '\n'); /* No separators => end of string => break. */ - if (cp == NULL) + if (tmp == NULL) break; + cp = tmp; /* Replace the separator with a terminator. */ *cp++ = '\0';