summaryrefslogtreecommitdiffstats
path: root/term-utils/wall.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 19:23:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 19:23:00 +0000
commit803b3a091c225d48395508a8f9ffa6e08cbddc5b (patch)
treea3168c9e7da8991c423b5978aacf90c3c2b135c1 /term-utils/wall.c
parentReleasing progress-linux version 2.40-8~progress7.99u1. (diff)
downloadutil-linux-803b3a091c225d48395508a8f9ffa6e08cbddc5b.tar.xz
util-linux-803b3a091c225d48395508a8f9ffa6e08cbddc5b.zip
Merging upstream version 2.40.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'term-utils/wall.c')
-rw-r--r--term-utils/wall.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/term-utils/wall.c b/term-utils/wall.c
index 588d3a9..125fde4 100644
--- a/term-utils/wall.c
+++ b/term-utils/wall.c
@@ -136,10 +136,17 @@ static gid_t get_group_gid(const char *group)
static struct group_workspace *init_group_workspace(const char *group)
{
- struct group_workspace *buf = xmalloc(sizeof(struct group_workspace));
+ struct group_workspace *buf;
+ long n;
+
+ n = sysconf(_SC_NGROUPS_MAX);
+ if (n < 0 || n > INT_MAX - 1)
+ return NULL;
+
+ buf = xmalloc(sizeof(struct group_workspace));
+ buf->ngroups = n + 1; /* room for the primary gid */
buf->requested_group = get_group_gid(group);
- buf->ngroups = sysconf(_SC_NGROUPS_MAX) + 1; /* room for the primary gid */
buf->groups = xcalloc(buf->ngroups, sizeof(*buf->groups));
return buf;
@@ -324,10 +331,10 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
if (print_banner == TRUE) {
char *hostname = xgethostname();
- char *whom, *where, date[CTIME_BUFSIZ];
+ char *whombuf, *whom, *where, date[CTIME_BUFSIZ];
time_t now;
- whom = xgetlogin();
+ whombuf = whom = xgetlogin();
if (!whom) {
whom = "<someone>";
warn(_("cannot get passwd uid"));
@@ -358,6 +365,7 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
whom, hostname, where, date);
fprintf(fs, "%-*.*s\007\007\r\n", TERM_WIDTH, TERM_WIDTH, lbuf);
free(hostname);
+ free(whombuf);
}
fprintf(fs, "%*s\r\n", TERM_WIDTH, " ");