Re: [gtk-list] Re: still a bug with getpwuid_r [was: Re: 1.1.14
- From: Sebastian Wilhelmi <wilhelmi ira uka de>
- To: gtk-list redhat com
- CC: Kevin Cozens <kcozens interlog com>
- Subject: Re: [gtk-list] Re: still a bug with getpwuid_r [was: Re: 1.1.14
- Date: Wed, 03 Feb 1999 09:40:25 +0100
Hi, Kevin
>
> At 02:49 PM 02/02/1999 +0100, you wrote:
> >> 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.
>
> This seems to be an awful hack. Surely there must be a better way to
> determine the size of the buffer that is needed.
Then please tell me. Remember the buffer is for holding information that
is fetched from different sources (/etc/passwd, nis, nis+, whatever) with
unkown and possibly unlimited size, for example on solaris the passwd
manpage does not specify a maximum size for the gcos field.
> I can picture g_malloc returning NULL when there isn't enough memory to
> allocate the buffer.
g_malloc will never return NULL. Period. This is not, because glib
delivers extra memory (why not actually ;-), but because g_malloc checks,
if malloc return NULL and aborts, if that is the case. As I already wrote
once, this IS good (In short: if there isn't any memory left, you will not
be able to do anything usefull in a sufficient complex program anyway.)
> The getpwuid_r() call assumes that the g_malloc() call succeeded. If it
> didn't it would seem to me that you have a big problem just waiting to
> happen.
See above.
> This might be ok for now until a better way is found. I don't think you
> want this in the 1.2 version of glib.
I suppose, it will remain in glib.
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 |
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]