[syslinux] [PATCH 1/1] : PCI detection code doesn't corrupt memory anymore
H. Peter Anvin
hpa at zytor.com
Sat Mar 8 02:39:18 PST 2008
Erwan wrote:
> From : Erwan Velu <erwan.velu at free.fr>
>
> This patch fixes the pci detection stuff demo'd in pcitest.c32
> - Fix a wrong type in malloc
> - Incorrect use of strdup
>
> This two fixes makes pcitest.c32 working far better, no more crash when
> running it twice.
>
> I'd like to thank Sebastian Herbszt for its reports and tests.
>
> This patch was made for 3.62-pre16 but applies fine on 3.63-pre1.
>
I notice you use strncpy() in a number of places here. strncpy() works
differently from just about all the other strn*() functions, in that it
doesn't make sure that the final output is zero-terminated. strncpy()
really is mostly to ensure that binary output doesn't leak information,
i.e. it produces *zero-padded* output (as opposed to zero-terminated.)
If you're looking for something that's equivalent to
"snprintf(dst, dst_len, "%s", src)" that's strlcpy() [which I'm not sure
if I have in libcom32, but can be trivially added if needed.]
-hpa
More information about the Syslinux
mailing list