From: Kai W. <kai...@gm...> - 2008-08-05 18:45:14
|
Sorry about the late reply, my $job is pushing me recently... On Sat, Aug 02, 2008 at 02:47:22PM -0000, Joseph Koshy wrote: > The strl*() APIs are cleaner, but I'm wondering if we should just bite > the bullet and stick to the portable APIs. > > For example: > > Index: elf_errmsg.c > =================================================================== > --- elf_errmsg.c (revision 209) > +++ elf_errmsg.c (working copy) > @@ -27,6 +27,7 @@ > #include <sys/cdefs.h> > > #include <libelf.h> > +#include <stdio.h> > #include <string.h> > > #include "_libelf.h" > @@ -74,11 +75,9 @@ > if (error < 0 || error >= ELF_E_NUM) > return _libelf_errors[ELF_E_NUM]; > if (oserr) { > - strlcpy(LIBELF_PRIVATE(msg), _libelf_errors[error], > - sizeof(LIBELF_PRIVATE(msg))); > - strlcat(LIBELF_PRIVATE(msg), ": ", sizeof(LIBELF_PRIVATE(msg))); > - strlcat(LIBELF_PRIVATE(msg), strerror(oserr), > - sizeof(LIBELF_PRIVATE(msg))); > + (void) snprintf(LIBELF_PRIVATE(msg), > + sizeof(LIBELF_PRIVATE(msg)), "%s: %s", > + _libelf_errors[error], strerror(oserr)); > return (const char *)&LIBELF_PRIVATE(msg); > } > return _libelf_errors[error]; > > > Comments? This looks great! I wasn't thinking of "snprintf"... I just tried compiling libelf r217 on Debian and I think the patches you committed today work well. Thanks, Kai |