Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <11455510.kDygYk5USg@main.pennware.com>
Date: Sat, 26 May 2012 16:05:28 -0500
From: Richard Pennington <rich@...nware.com>
To: musl@...ts.openwall.com
Subject: A small bug in strrchr

Hi,

I found a small bug in strrchr(). 

strrchr("string", '\0') does not return a pointer to the trailing nul byte.

Here is the corrected version:


#include <string.h>

void *__memrchr(const void *, int, size_t);

char *strrchr(const char *s, int c)
{
        return __memrchr(s, c, strlen(s) + 1);
}

(I added the + 1)

-Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.