9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: arisawa@ar.aichi-u.ac.jp
To: 9fans@cse.psu.edu
Subject: Re: [9fans] libc/strcmp bug?
Date: Sat, 10 Aug 2002 14:44:38 +0900	[thread overview]
Message-ID: <bf30e8eb82cfb5af34268d9d41a83e02@ar.aichi-u.ac.jp> (raw)
In-Reply-To: <Pine.GSO.4.21.0208100044580.7304-100000@weyl.math.psu.edu>

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


  reply	other threads:[~2002-08-10  5:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-10  0:35 Skip Tavakkolian
2002-08-10  4:46 ` Alexander Viro
2002-08-10  5:44   ` arisawa [this message]
2002-08-10 23:43 ` david presotto
2002-08-10  3:23 Skip Tavakkolian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bf30e8eb82cfb5af34268d9d41a83e02@ar.aichi-u.ac.jp \
    --to=arisawa@ar.aichi-u.ac.jp \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).