From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Content-Type: text/plain MIME-Version: 1.0 (NeXT Mail 3.3ciscupdate v148.2.1) From: arisawa@ar.aichi-u.ac.jp To: 9fans@cse.psu.edu Subject: Re: [9fans] libc/strcmp bug? References: Date: Sat, 10 Aug 2002 14:44:38 +0900 Topicbox-Message-UUID: da024b6e-eaca-11e9-9e20-41e7f4b1d025 Hello, Viro said: >On Fri, 9 Aug 2002, Skip Tavakkolian wrote: > >> I believe there is a bug in /sys/src/libc/port/strcmp.c, because it >> does not check for null pointers getting passed in before >> dereferencing them. > >Not a libc bug. Making sure that arguments of strcmp() are non-NULL >is responsibility of caller. I agree with Viro. If null pointer is allowed, strcmp() should be something like bellow: int xstrcmp(char *s, char *t) { if(s == nil){ if(t) return -1; return 0; } if(t) return strcmp(s,t); return 1; } I used this code somewhere because it was useful. Kenji Arisawa