One more problem:
Tim Waugh wrote:
> + buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
> + buf = malloc (buflen);
> + if (buf == NULL)
> + return (-1);
> +
> + if (getpwnam_r (cupsUser(), &pwbuf, buf, buflen, &pwbufptr) != 0)
> + {
> + free (buf);
The result of the sysconf() call is a first best guess. It's is not
necessarily enough. In fact, there is no fixed upper limit for the size
of the buffer that is needed. The code should look something like this:
buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
buf = NULL;
again:
newbuf = realloc (buf, buflen);
if (newbuf == NULL)
{
free (buf);
return -1;
}
buf = newbuf;
r = getpwnam_r (cupsUser(), &pwbuf, buf, buflen, &pwbufptr);
if (r != 0)
{
if (r == ERANGE)
{
buflen *= 2;
goto again;
}
free (buf);
return -1;
}
--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
signature.asc
Description: OpenPGP digital signature
-- redhat-lspp mailing list [email protected] https://www.redhat.com/mailman/listinfo/redhat-lspp
