[uClibc]strcmp
David Meggy
dmeggy at techsol.ca
Wed Nov 13 21:23:37 UTC 2002
Hi, I'm trying to upgrade to the new version of uClibc and I've run into
a problem with strcmp, with using wide character support and without
wide character support.
In libc/string/wstring.c
int Wstrcmp(register const Wchar *s1, register const Wchar *s2)
{
#ifdef WANT_WIDE
while (*((Wuchar *)s1) == *((Wuchar *)s2)) {
if (!*s1++) {
return 0;
}
++s2;
}
return (*((Wuchar *)s1) < *((Wuchar *)s2)) ? -1 : 1;
#else
int r;
while (((r = ((int)(*((Wuchar *)s1))) - *((Wuchar *)s2++))
== 0) && *s1++);
return r;
#endif
}
I'm having problems when s1 = NULL. The function never checks for this
case. If it isn't the C library's responsibility to check then there is
a bug in Busybox. I run into this problem when init_main calls strcmp.
Shown here:
extern int init_main(int argc, char **argv)
{
struct init_action *a;
pid_t wpid;
int status;
if (argc > 1 && !strcmp(argv[1], "-q")) {
/* don't assume init's pid == 1 */
long *pid = find_pid_by_name("init");
if (!pid || *pid<=0) {
Now if argc is > 1 then argv[1] should be valid, unless busybox passed
incorrect values into this function.
I'm still looking into this. I posted this to uClibc since it was
upgrading uClibc that caused this problem, although it does look like
there is something wrong with busybox.
David
--
~~~~~~~~~~~~~~~~~~~~~~~~
David Meggy
Engineering
Technical Solutions Inc.
Unit #1 7157 Honeyman St
Delta BC Canada, V4G 1E2
www.techsol.ca
eMail: dmeggy at techsol.ca
Tel: 604 946 TECH (8324)
Fax: 604 946 6445
~~~~~~~~~~~~~~~~~~~~~~~~
More information about the uClibc
mailing list