This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sim/arm/armos.c: IsTTY [PATCH]


On Wed, 2005-09-07 at 17:51, Shaun Jackman wrote:
> 2005/8/29, Daniel Jacobowitz <drow@false.org>:
> > 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  <sjackman@gmail.com>
> 
> 	* 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]