From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12432 invoked by alias); 7 Feb 2012 20:17:29 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30188 Received: (qmail 9276 invoked from network); 7 Feb 2012 20:17:25 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at bewatermyfriend.org does not designate permitted sender hosts) From: Frank Terbeck To: "Timothy Redaelli" Cc: zsh-workers@zsh.org Subject: Re: [PATCH] GNU canonicalize_file_name can return a NULL pointer In-Reply-To: (Timothy Redaelli's message of "Tue, 07 Feb 2012 19:45:48 +0100") References: User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.91 (gnu/linux) Date: Tue, 07 Feb 2012 21:10:58 +0100 Message-ID: <87r4y6e759.fsf@ft.bewatermyfriend.org> MIME-Version: 1.0 Content-Type: text/plain X-Df-Sender: [pbs]MDExNTM1 Timothy Redaelli wrote: > In Src/hist.c on line 1668 there is a NULL pointer dereference because > GNU canonicalize_file_name returns NULL on some errors. > > In attachment you will find a small patch that fixes that bug. Thanks! I've looked at the code and it bails out for a couple of errors in `errno'. I've looked at how canonicalize_file_name() is implemented by glibc, and it's just a short hand for "realpath(foo, NULL)". So at least on GNU systems the errors from realpath(3) apply to canonicalize_file_name(), too. Here's the current standard: I don't know if it's worth checking all those or just go with bailing out if `real' is NULL. Both HAVE_REALPATH and HAVE_CANONICALIZE_FILE_NAME use a `real' pointer, so I think the "if (!null)" test should be in there unconditionally, without the `#ifdef'. Comments? Regards, Frank