diff options
author | Jim Meyering <jim@meyering.net> | 2003-02-06 10:22:12 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-02-06 10:22:12 +0000 |
commit | adb8e94a33e82879a0d0343dcd100f79ba847650 (patch) | |
tree | a6f129b0edd7a1bd234e696fe755d1b87ccb4b83 /src | |
parent | 4138c9ef9f05d86aaab22257cfa471f794eeca56 (diff) | |
download | coreutils-adb8e94a33e82879a0d0343dcd100f79ba847650.tar.xz |
(print_boottime, print_deadprocs, print_runlevel):
Fix memory allocation arithmetic.
Diffstat (limited to 'src')
-rw-r--r-- | src/who.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1,5 +1,5 @@ /* GNU's who. - Copyright (C) 1992-2002 Free Software Foundation, Inc. + Copyright (C) 1992-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -384,7 +384,7 @@ print_boottime (const STRUCT_UTMP *utmp_ent) static char * make_id_equals_comment (STRUCT_UTMP const *utmp_ent) { - char *comment = xmalloc (sizeof (_("id=")) + sizeof UT_ID (utmp_ent) + 1); + char *comment = xmalloc (strlen (_("id=")) + sizeof UT_ID (utmp_ent) + 1); /* Cast field width argument to `int' to avoid warning from gcc. */ sprintf (comment, "%s%.*s", _("id="), (int) sizeof UT_ID (utmp_ent), @@ -400,9 +400,9 @@ print_deadprocs (const STRUCT_UTMP *utmp_ent) PIDSTR_DECL_AND_INIT (pidstr, utmp_ent); if (!exitstr) - exitstr = xmalloc (sizeof (_("term=")) + exitstr = xmalloc (strlen (_("term=")) + INT_STRLEN_BOUND (UT_EXIT_E_TERMINATION (utmp_ent)) + 1 - + sizeof (_("exit=")) + + strlen (_("exit=")) + INT_STRLEN_BOUND (UT_EXIT_E_EXIT (utmp_ent)) + 1); sprintf (exitstr, "%s%d %s%d", _("term="), UT_EXIT_E_TERMINATION (utmp_ent), @@ -455,11 +455,11 @@ print_runlevel (const STRUCT_UTMP *utmp_ent) int curr = UT_PID (utmp_ent) % 256; if (!runlevline) - runlevline = xmalloc (sizeof (_("run-level")) + 3); + runlevline = xmalloc (strlen (_("run-level")) + 3); sprintf (runlevline, "%s %c", _("run-level"), curr); if (!comment) - comment = xmalloc (sizeof (_("last=")) + 2); + comment = xmalloc (strlen (_("last=")) + 2); sprintf (comment, "%s%c", _("last="), (last == 'N') ? 'S' : last); print_line ("", ' ', runlevline, time_string (utmp_ent), |