mirror of
git://sourceware.org/git/glibc.git
synced 2025-01-30 12:31:53 +08:00
Update.
1999-06-28 Andreas Jaeger <aj@arthur.rhein-neckar.de> * inet/rcmd.c (__icheckhost): Test for gethostbyname_r result correctly. 1999-06-25 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/arith.texi (System V Number Conversion): Fix the description which confused pointer and value to pointer. Reported by Andries.Brouwer@cwi.nl. 1999-06-28 Andreas Jaeger <aj@arthur.rhein-neckar.de> * pwd/getpw.c (__getpw): Check for NULL result pointer. 1999-06-29 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/users.texi (Lookup User): Document POSIX return semantics for getpwuid_r and getgrgid_r. * manual/socket.texi (Host Names): Document that the result pointer is null in case of error or host not found and fix a typo. Give a small example.
This commit is contained in:
parent
16848c985d
commit
0ea5db4f1f
24
ChangeLog
24
ChangeLog
@ -1,3 +1,27 @@
|
|||||||
|
1999-06-28 Andreas Jaeger <aj@arthur.rhein-neckar.de>
|
||||||
|
|
||||||
|
* inet/rcmd.c (__icheckhost): Test for gethostbyname_r result
|
||||||
|
correctly.
|
||||||
|
|
||||||
|
1999-06-25 Andreas Jaeger <aj@arthur.rhein-neckar.de>
|
||||||
|
|
||||||
|
* manual/arith.texi (System V Number Conversion): Fix the
|
||||||
|
description which confused pointer and value to pointer.
|
||||||
|
Reported by Andries.Brouwer@cwi.nl.
|
||||||
|
|
||||||
|
1999-06-28 Andreas Jaeger <aj@arthur.rhein-neckar.de>
|
||||||
|
|
||||||
|
* pwd/getpw.c (__getpw): Check for NULL result pointer.
|
||||||
|
|
||||||
|
1999-06-29 Andreas Jaeger <aj@arthur.rhein-neckar.de>
|
||||||
|
|
||||||
|
* manual/users.texi (Lookup User): Document POSIX return
|
||||||
|
semantics for getpwuid_r and getgrgid_r.
|
||||||
|
|
||||||
|
* manual/socket.texi (Host Names): Document that the result
|
||||||
|
pointer is null in case of error or host not found and fix a
|
||||||
|
typo. Give a small example.
|
||||||
|
|
||||||
1999-06-30 Ulrich Drepper <drepper@cygnus.com>
|
1999-06-30 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
* pwd/getpw.c: Add warning since no buffer size is given and
|
* pwd/getpw.c: Add warning since no buffer size is given and
|
||||||
|
@ -270,7 +270,7 @@ ruserok(rhost, superuser, ruser, luser)
|
|||||||
buffer = __alloca (buflen);
|
buffer = __alloca (buflen);
|
||||||
|
|
||||||
while (__gethostbyname_r (rhost, &hostbuf, buffer, buflen, &hp, &herr)
|
while (__gethostbyname_r (rhost, &hostbuf, buffer, buflen, &hp, &herr)
|
||||||
< 0)
|
!= 0)
|
||||||
if (herr != NETDB_INTERNAL || errno != ERANGE)
|
if (herr != NETDB_INTERNAL || errno != ERANGE)
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
|
@ -2191,13 +2191,13 @@ All these functions are defined in @file{stdlib.h}.
|
|||||||
@comment SVID, Unix98
|
@comment SVID, Unix98
|
||||||
@deftypefun {char *} ecvt (double @var{value}, int @var{ndigit}, int *@var{decpt}, int *@var{neg})
|
@deftypefun {char *} ecvt (double @var{value}, int @var{ndigit}, int *@var{decpt}, int *@var{neg})
|
||||||
The function @code{ecvt} converts the floating-point number @var{value}
|
The function @code{ecvt} converts the floating-point number @var{value}
|
||||||
to a string with at most @var{ndigit} decimal digits.
|
to a string with at most @var{ndigit} decimal digits. The
|
||||||
The returned string contains no decimal point or sign. The first
|
returned string contains no decimal point or sign. The first digit of
|
||||||
digit of the string is non-zero (unless @var{value} is actually zero)
|
the string is non-zero (unless @var{value} is actually zero) and the
|
||||||
and the last digit is rounded to nearest. @var{decpt} is set to the
|
last digit is rounded to nearest. @code{*@var{decpt}} is set to the
|
||||||
index in the string of the first digit after the decimal point.
|
index in the string of the first digit after the decimal point.
|
||||||
@var{neg} is set to a nonzero value if @var{value} is negative, zero
|
@code{*@var{neg}} is set to a nonzero value if @var{value} is negative,
|
||||||
otherwise.
|
zero otherwise.
|
||||||
|
|
||||||
If @var{ndigit} decimal digits would exceed the precision of a
|
If @var{ndigit} decimal digits would exceed the precision of a
|
||||||
@code{double} it is reduced to a system-specific value.
|
@code{double} it is reduced to a system-specific value.
|
||||||
@ -2205,16 +2205,16 @@ If @var{ndigit} decimal digits would exceed the precision of a
|
|||||||
The returned string is statically allocated and overwritten by each call
|
The returned string is statically allocated and overwritten by each call
|
||||||
to @code{ecvt}.
|
to @code{ecvt}.
|
||||||
|
|
||||||
If @var{value} is zero, it's implementation defined whether @var{decpt} is
|
If @var{value} is zero, it is implementation defined whether
|
||||||
@code{0} or @code{1}.
|
@code{*@var{decpt}} is @code{0} or @code{1}.
|
||||||
|
|
||||||
For example: @code{ecvt (12.3, 5, &decpt, &neg)} returns @code{"12300"}
|
For example: @code{ecvt (12.3, 5, &d, &n)} returns @code{"12300"}
|
||||||
and sets @var{decpt} to @code{2} and @var{neg} to @code{0}.
|
and sets @var{d} to @code{2} and @var{n} to @code{0}.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
@comment stdlib.h
|
@comment stdlib.h
|
||||||
@comment SVID, Unix98
|
@comment SVID, Unix98
|
||||||
@deftypefun {char *} fcvt (double @var{value}, int @var{ndigit}, int @var{decpt}, int *@var{neg})
|
@deftypefun {char *} fcvt (double @var{value}, int @var{ndigit}, int *@var{decpt}, int *@var{neg})
|
||||||
The function @code{fcvt} is like @code{ecvt}, but @var{ndigit} specifies
|
The function @code{fcvt} is like @code{ecvt}, but @var{ndigit} specifies
|
||||||
the number of digits after the decimal point. If @var{ndigit} is less
|
the number of digits after the decimal point. If @var{ndigit} is less
|
||||||
than zero, @var{value} is rounded to the @math{@var{ndigit}+1}'th place to the
|
than zero, @var{value} is rounded to the @math{@var{ndigit}+1}'th place to the
|
||||||
@ -2254,7 +2254,7 @@ restricted by the precision of a @code{long double}.
|
|||||||
|
|
||||||
@comment stdlib.h
|
@comment stdlib.h
|
||||||
@comment GNU
|
@comment GNU
|
||||||
@deftypefun {char *} qfcvt (long double @var{value}, int @var{ndigit}, int @var{decpt}, int *@var{neg})
|
@deftypefun {char *} qfcvt (long double @var{value}, int @var{ndigit}, int *@var{decpt}, int *@var{neg})
|
||||||
This function is equivalent to @code{fcvt} except that it
|
This function is equivalent to @code{fcvt} except that it
|
||||||
takes a @code{long double} for the first parameter and that @var{ndigit} is
|
takes a @code{long double} for the first parameter and that @var{ndigit} is
|
||||||
restricted by the precision of a @code{long double}.
|
restricted by the precision of a @code{long double}.
|
||||||
@ -2292,7 +2292,7 @@ This function is a GNU extension.
|
|||||||
|
|
||||||
@comment stdlib.h
|
@comment stdlib.h
|
||||||
@comment SVID, Unix98
|
@comment SVID, Unix98
|
||||||
@deftypefun {char *} fcvt_r (double @var{value}, int @var{ndigit}, int @var{decpt}, int *@var{neg}, char *@var{buf}, size_t @var{len})
|
@deftypefun {char *} fcvt_r (double @var{value}, int @var{ndigit}, int *@var{decpt}, int *@var{neg}, char *@var{buf}, size_t @var{len})
|
||||||
The @code{fcvt_r} function is the same as @code{fcvt}, except
|
The @code{fcvt_r} function is the same as @code{fcvt}, except
|
||||||
that it places its result into the user-specified buffer pointed to by
|
that it places its result into the user-specified buffer pointed to by
|
||||||
@var{buf}, with length @var{len}.
|
@var{buf}, with length @var{len}.
|
||||||
@ -2312,7 +2312,7 @@ This function is a GNU extension.
|
|||||||
|
|
||||||
@comment stdlib.h
|
@comment stdlib.h
|
||||||
@comment GNU
|
@comment GNU
|
||||||
@deftypefun {char *} qfcvt_r (long double @var{value}, int @var{ndigit}, int @var{decpt}, int *@var{neg}, char *@var{buf}, size_t @var{len})
|
@deftypefun {char *} qfcvt_r (long double @var{value}, int @var{ndigit}, int *@var{decpt}, int *@var{neg}, char *@var{buf}, size_t @var{len})
|
||||||
The @code{qfcvt_r} function is the same as @code{qfcvt}, except
|
The @code{qfcvt_r} function is the same as @code{qfcvt}, except
|
||||||
that it places its result into the user-specified buffer pointed to by
|
that it places its result into the user-specified buffer pointed to by
|
||||||
@var{buf}, with length @var{len}.
|
@var{buf}, with length @var{len}.
|
||||||
|
@ -1284,13 +1284,42 @@ pointer and the size of the buffer in the @var{buf} and @var{buflen}
|
|||||||
parameters.
|
parameters.
|
||||||
|
|
||||||
A pointer to the buffer, in which the result is stored, is available in
|
A pointer to the buffer, in which the result is stored, is available in
|
||||||
@code{*@var{result}} after the function call successfully returned.
|
@code{*@var{result}} after the function call successfully returned. If
|
||||||
Success is signalled by a zero return value. If the function failed the
|
an error occurs or if no entry is found, the pointer @code{*var{result}
|
||||||
return value is an error number. In addition to the errors defined for
|
is a null pointer. Success is signalled by a zero return value. If the
|
||||||
@code{gethostbyname} it can also be @code{ERANGE}. In this case the
|
function failed the return value is an error number. In addition to the
|
||||||
call should be repeated with a larger buffer. Additional error
|
errors defined for @code{gethostbyname} it can also be @code{ERANGE}.
|
||||||
information is not stored in the global variable @code{h_errno} but
|
In this case the call should be repeated with a larger buffer.
|
||||||
instead in the object pointed to by @var{h_errnop}.
|
Additional error information is not stored in the global variable
|
||||||
|
@code{h_errno} but instead in the object pointed to by @var{h_errnop}.
|
||||||
|
|
||||||
|
Here's a small example:
|
||||||
|
@smallexample
|
||||||
|
struct hostent *
|
||||||
|
gethostname (char *host)
|
||||||
|
@{
|
||||||
|
struct hostent hostbuf, *hp;
|
||||||
|
size_t hstbuflen;
|
||||||
|
char *tmphstbuf;
|
||||||
|
int res;
|
||||||
|
int herr;
|
||||||
|
|
||||||
|
hstbuflen = 1024;
|
||||||
|
tmphstbuf = malloc (hstbuflen);
|
||||||
|
|
||||||
|
while ((res = gethostbyname_r (host, &hostbuf, tmphstbuf, hstbuflen,
|
||||||
|
&hp, &herr)) == ERANGE)
|
||||||
|
@{
|
||||||
|
/* Enlarge the buffer. */
|
||||||
|
hstbuflen *= 2;
|
||||||
|
tmphstbuf = realloc (tmphstbuf, hstbuflen);
|
||||||
|
@}
|
||||||
|
/* Check for errors. */
|
||||||
|
if (res || hp == NULL)
|
||||||
|
return NULL;
|
||||||
|
return hp->h_name;
|
||||||
|
@}
|
||||||
|
@end smallexample
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
@comment netdb.h
|
@comment netdb.h
|
||||||
@ -1314,7 +1343,7 @@ Internet address, use @code{AF_INET6}.
|
|||||||
|
|
||||||
Similar to the @code{gethostbyname_r} function, the caller must provide
|
Similar to the @code{gethostbyname_r} function, the caller must provide
|
||||||
buffers for the result and memory used internally. In case of success
|
buffers for the result and memory used internally. In case of success
|
||||||
the funciton returns zero. Otherwise the value is an error number where
|
the function returns zero. Otherwise the value is an error number where
|
||||||
@code{ERANGE} has the special meaning that the caller-provided buffer is
|
@code{ERANGE} has the special meaning that the caller-provided buffer is
|
||||||
too small.
|
too small.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
@ -1479,12 +1479,14 @@ the information instead of using a static buffer. The first
|
|||||||
are used to contain additional information, normally strings which are
|
are used to contain additional information, normally strings which are
|
||||||
pointed to by the elements of the result structure.
|
pointed to by the elements of the result structure.
|
||||||
|
|
||||||
If the return value is @code{0} the pointer returned in @var{result}
|
If a user with ID @var{uid} is found, the pointer returned in
|
||||||
points to the record which contains the wanted data (i.e., @var{result}
|
@var{result} points to the record which contains the wanted data (i.e.,
|
||||||
contains the value @var{result_buf}). If it is nonzero, there is no
|
@var{result} contains the value @var{result_buf}). If no user is found
|
||||||
user in the data base with user ID @var{uid}, or the buffer @var{buffer}
|
or if an error occured, the pointer returned in @var{result} is a null
|
||||||
is too small to contain all the needed information. In the latter case,
|
pointer. The function returns zero or an error code. If the buffer
|
||||||
@var{errno} is set to @code{ERANGE}.
|
@var{buffer} is too small to contain all the needed information, the
|
||||||
|
error code @code{ERANGE} is returned and @var{errno} is set to
|
||||||
|
@code{ERANGE}.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
|
|
||||||
@ -1690,12 +1692,14 @@ the information instead of using a static buffer. The first
|
|||||||
are used to contain additional information, normally strings which are
|
are used to contain additional information, normally strings which are
|
||||||
pointed to by the elements of the result structure.
|
pointed to by the elements of the result structure.
|
||||||
|
|
||||||
If the return value is @code{0} the pointer returned in @var{result}
|
If a group with ID @var{gid} is found, the pointer returned in
|
||||||
points to the requested data (i.e., @var{result} contains the value
|
@var{result} points to the record which contains the wanted data (i.e.,
|
||||||
@var{result_buf}). If it is nonzero, there is no group in the data base
|
@var{result} contains the value @var{result_buf}). If no group is found
|
||||||
with group ID @var{gid}, or the buffer @var{buffer} is too small to
|
or if an error occured, the pointer returned in @var{result} is a null
|
||||||
contain all the needed information. In the latter case, @var{errno} is
|
pointer. The function returns zero or an error code. If the buffer
|
||||||
set to @code{ERANGE}.
|
@var{buffer} is too small to contain all the needed information, the
|
||||||
|
error code @code{ERANGE} is returned and @var{errno} is set to
|
||||||
|
@code{ERANGE}.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
@comment grp.h
|
@comment grp.h
|
||||||
|
@ -50,6 +50,9 @@ __getpw (uid, buf)
|
|||||||
if (__getpwuid_r (uid, &resbuf, tmpbuf, buflen, &p) != 0)
|
if (__getpwuid_r (uid, &resbuf, tmpbuf, buflen, &p) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (sprintf (buf, "%s:%s:%lu:%lu:%s:%s:%s", p->pw_name, p->pw_passwd,
|
if (sprintf (buf, "%s:%s:%lu:%lu:%s:%s:%s", p->pw_name, p->pw_passwd,
|
||||||
(unsigned long int) p->pw_uid, (unsigned long int) p->pw_gid,
|
(unsigned long int) p->pw_uid, (unsigned long int) p->pw_gid,
|
||||||
p->pw_gecos, p->pw_dir, p->pw_shell) < 0)
|
p->pw_gecos, p->pw_dir, p->pw_shell) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user