Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 9 Jun 2015 21:17:47 +0200
From: Alex <alexinbeijing@...il.com>
To: musl@...ts.openwall.com
Subject: Re: getgrgid and errno

The code which you show says "if (rv) errno = rv". The debugger shows that
rv is 0. So the condition is false and errno is not set.

It must have been set to ENOENT somewhere above that -- as you single-step
through the code, keep printing errno on each line to find out where.

On Tue, Jun 9, 2015 at 2:59 PM, Julien Ramseier <j.ramseier@...il.com>
wrote:

> Hello,
>
> I’m encountering a strange problem with getgrgid.
>
> Calling this function with a non-existent group sets errno to ENOENT
> instead of 0.
> This small test program below prints getgrgid: No such file or directory.
>
> #include <sys/types.h>
> #include <grp.h>
> #include <stddef.h>
> #include <errno.h>
>
> int main(void) {
> errno = 0;
> struct group *g = getgrgid(1234);
> perror("getgrgid");
> }
>
> However, when stepping through __getgr_a with gdb, errno seems to be
> correctly set to 0:
>
> 167 if (rv) errno = rv;
> (gdb)
> 168 return rv;
> (gdb) p rv
> $6 = 0
>
> So I really don’t know what’s going on…Am I missing something?
>
> -
> Julien
>

Content of type "text/html" skipped

Powered by blists - more mailing lists

Your e-mail address:

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