Re: [gtk-list] Re: still a bug with getpwuid_r [was: Re: 1.1.14




I'm not so certain.  Why does my program crash in gtk_init when the
line is as below, but is ok when the commented out code is used?

 guint bufsize = 1; /* sizeof (struct passwd); */

I agree the man page says it SHOULD be ok (from a Solaris 2.6 man
page):

ERRORS
     The   reentrant   functions   getpwnam_r(),    getpwuid_r(),
     getpwent_r(),  and  fgetpwent_r()  will  return NULL and set
     errno  to  ERANGE  (or  in  the  case  of  POSIX   functions
     getpwnam_r()  and  getpwuid_r()  return the ERANGE error) if
     the length of the buffer supplied by  caller  is  not  large
     enough  to  store  the  result.  See Intro(2) for the proper
     usage and interpretation of errno in multithreaded  applica-
     tions.

But for some reason it isn't.  Is the code checking the error result
of error correct?  It appears to me to be ok, but I'm not certain.


> From: Trog <trog@gtk.org>
>
> Doh! Should be fine then.
> 
> <wanders off to find a paper bag>
> 
> -tony
> 
> 
> On 02-Feb-99 Sebastian Wilhelmi wrote:
> > Hi,
> >  
> >> Doubled by whom? 
> > 
> > By glib: here's the source:
> > 
> >         do
> >           {
> >             g_free (buffer);
> >             buffer = g_malloc (bufsize);
> > 
> >#    ifdef HAVE_GETPWUID_R_POSIX
> >             error = getpwuid_r (getuid (), &pwd, buffer, bufsize,
> > &pw);
> >             error = error < 0 ? errno : error;
> >#    else /* !HAVE_GETPWUID_R_POSIX */
> >             pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
> >             error = pw ? 0 : errno;
> >#    endif /* !HAVE_GETPWUID_R_POSIX */
> > 
> >             bufsize *= 2; /* here the bufzise gets doubled */
> >           }
> >         while (error == ERANGE); /* This loop us left, whenever the
> > call
> >                                     to getpwuid succeded. */
> > 
> > 
> >> Don't forget that we are working on multiple
> >> architectures, and the Digital UNIX man page seems very specific.
> >> 
> >> I'd rather have it suffice in all situations rather than most.
> > 
> > I still think, it should work on DIGITAL as well.
> > 
> > Bye,
> > Sebastian
> > -- 
> > Sebastian Wilhelmi                   |            här ovanför alla
> > molnen
> > mailto:wilhelmi@ira.uka.de           |      är himmlen så
> > förunerligt blå
> > http://goethe.ira.uka.de/~wilhelmi   |
> 
> ---
> E-Mail: trog@gtk.org
> If the facts don't fit the theory, change the facts.
> 		-- Albert Einstein
> 
> Go Bezerk! http://www.gtk.org/~trog



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]