From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2056 invoked by alias); 8 Sep 2005 09:07:05 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 1924 invoked by uid 22791); 8 Sep 2005 09:06:48 -0000 Received: from cam-admin0.cambridge.arm.com (HELO cam-admin0.cambridge.arm.com) (193.131.176.58) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 08 Sep 2005 09:06:48 +0000 Received: from pc960.cambridge.arm.com (pc960.cambridge.arm.com [10.1.205.4]) by cam-admin0.cambridge.arm.com (8.12.10/8.12.10) with ESMTP id j8896MQb013733; Thu, 8 Sep 2005 10:06:22 +0100 (BST) Received: from pc960.cambridge.arm.com (localhost.localdomain [127.0.0.1]) by pc960.cambridge.arm.com (8.12.8/8.12.8) with ESMTP id j8896TGt019373; Thu, 8 Sep 2005 10:06:29 +0100 Received: (from rearnsha@localhost) by pc960.cambridge.arm.com (8.12.8/8.12.8/Submit) id j8896SCR019371; Thu, 8 Sep 2005 10:06:28 +0100 Subject: Re: sim/arm/armos.c: IsTTY [PATCH] From: Richard Earnshaw To: sjackman@gmail.com Cc: gdb-patches@sources.redhat.com In-Reply-To: <7f45d93905090709516f912861@mail.gmail.com> References: <7f45d9390508151204ca0b146@mail.gmail.com> <20050830023718.GB16189@nevyn.them.org> <7f45d93905090709516f912861@mail.gmail.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1126170388.18092.16.camel@pc960.cambridge.arm.com> Mime-Version: 1.0 Date: Thu, 08 Sep 2005 09:07:00 -0000 X-SW-Source: 2005-09/txt/msg00052.txt.bz2 On Wed, 2005-09-07 at 17:51, Shaun Jackman wrote: > 2005/8/29, Daniel Jacobowitz : > > Please no buffer overflows be adding. Also, there's plenty of ways to > > write this without the ugly empty loop body... > > I fixed the potential buffer overflow and cleaned up the loop coding > style. Thanks for the tips. > > Cheers, > Shaun > > 2005-09-07 Shaun Jackman > > * sim/arm/armos.c (unlink): Remove this macro. It is unused > in this file and conflicts with sim_callback->unlink. > (SWIopen): Fix a potential buffer overflow. > (SWIremove): New function. > (SWIrename): Ditto. > (ARMul_OSHandleSWI): Handle the RDP calls SWI_IsTTY, > SWI_Remove, and SWI_Rename, as well as the RDI calls > AngelSWI_Reason_IsTTY, AngelSWI_Reason_Remove, and > AngelSWI_Reason_Rename. > Two problems I can immediately see with this. 1) PATH_MAX isn't ANSI (it's POSIX, or something like that). So you can't rely on it being defined. I think for this case you can probably just define it to 1024 anyway if it's missing, but see libiberty/lrealpath.c if you want the gory details. 2) If you do overflow the path limit, you need to set the simulator's errno value and return. Use cb_host_to_target_errno(sim_callback, ENAMETOOLONG) to set it. R.