This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Bug in MIPS strncpy
- From: "Perry McFarlane" <perry_m at fastmail dot fm>
- To: newlib at sourceware dot org
- Date: Thu, 26 Jun 2008 20:23:07 -0700
- Subject: Bug in MIPS strncpy
I found a bug in the MIPS-optimized strncpy
(newlib/libc/machine/mips/strncpy.c)
There is an unrolled loop to read from the source string 4 bytes at a
time, but this could read past the \0 and cause a SEGV.
The MIPS-optimized strncpy was added as part of this patch:
http://sourceware.org/ml/newlib/2001/msg00594.html
I suppose that it could be fixed by only reading groups of 4 bytes that
are word-alligned.
--
Perry McFarlane
perry_m@fastmail.fm
--
http://www.fastmail.fm - IMAP accessible web-mail