aboutsummaryrefslogtreecommitdiff
path: root/manual/users.texi
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-04-11 19:06:00 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2021-04-13 12:17:56 -0700
commitbdc674d97ba8b59e22b1f45fa1a37862764fcc75 (patch)
tree66b8438f974eb3910663d1a0f047f256de376f50 /manual/users.texi
parentcedbf6d5f3f70ca911176de87d6e453eeab4b7a1 (diff)
downloadglibc-bdc674d97ba8b59e22b1f45fa1a37862764fcc75.tar
glibc-bdc674d97ba8b59e22b1f45fa1a37862764fcc75.tar.gz
glibc-bdc674d97ba8b59e22b1f45fa1a37862764fcc75.tar.bz2
glibc-bdc674d97ba8b59e22b1f45fa1a37862764fcc75.zip
Improve documentation for malloc etc. (BZ#27719)
Cover key corner cases (e.g., whether errno is set) that are well settled in glibc, fix some examples to avoid integer overflow, and update some other dated examples (code needed for K&R C, e.g.). * manual/charset.texi (Non-reentrant String Conversion): * manual/filesys.texi (Symbolic Links): * manual/memory.texi (Allocating Cleared Space): * manual/socket.texi (Host Names): * manual/string.texi (Concatenating Strings): * manual/users.texi (Setting Groups): Use reallocarray instead of realloc, to avoid integer overflow issues. * manual/filesys.texi (Scanning Directory Content): * manual/memory.texi (The GNU Allocator, Hooks for Malloc): * manual/tunables.texi: Use code font for 'malloc' instead of roman font. (Symbolic Links): Don't assume readlink return value fits in 'int'. * manual/memory.texi (Memory Allocation and C, Basic Allocation) (Malloc Examples, Alloca Example): * manual/stdio.texi (Formatted Output Functions): * manual/string.texi (Concatenating Strings, Collation Functions): Omit pointer casts that are needed only in ancient K&R C. * manual/memory.texi (Basic Allocation): Say that malloc sets errno on failure. Say "convert" rather than "cast", since casts are no longer needed. * manual/memory.texi (Basic Allocation): * manual/string.texi (Concatenating Strings): In examples, use C99 declarations after statements for brevity. * manual/memory.texi (Malloc Examples): Add portability notes for malloc (0), errno setting, and PTRDIFF_MAX. (Changing Block Size): Say that realloc (p, 0) acts like (p ? (free (p), NULL) : malloc (0)). Add xreallocarray example, since other examples can use it. Add portability notes for realloc (0, 0), realloc (p, 0), PTRDIFF_MAX, and improve notes for reallocating to the same size. (Allocating Cleared Space): Reword now-confusing discussion about replacement, and xref "Replacing malloc". * manual/stdio.texi (Formatted Output Functions): Don't assume message size fits in 'int'. * manual/string.texi (Concatenating Strings): Fix undefined behavior involving arithmetic on a freed pointer.
Diffstat (limited to 'manual/users.texi')
-rw-r--r--manual/users.texi2
1 files changed, 1 insertions, 1 deletions
diff --git a/manual/users.texi b/manual/users.texi
index ec22ce6c1c..72da3fb714 100644
--- a/manual/users.texi
+++ b/manual/users.texi
@@ -578,7 +578,7 @@ supplementary_groups (char *user)
if (getgrouplist (pw->pw_name, pw->pw_gid, groups, &ngroups) < 0)
@{
- groups = xrealloc (ngroups * sizeof (gid_t));
+ groups = xreallocarray (ngroups, sizeof *groups);
getgrouplist (pw->pw_name, pw->pw_gid, groups, &ngroups);
@}
return groups;