Use safer allocation macros
Use of these macros, apart from the benefits mentioned in the commit that adds the macros, has some other good side effects: - Consistency in getting the size of the object from sizeof(type), instead of a mix of sizeof(type) sometimes and sizeof(*p) other times. - More readable code: no casts, and no sizeof(), so also shorter lines that we don't need to cut. - Consistency in using array allocation calls for allocations of arrays of objects, even when the object size is 1. Cc: Valentin V. Bartenev <vbartenev@gmail.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
6e58c12752
commit
efbbcade43
@@ -24,6 +24,8 @@
|
||||
#include <pwd.h>
|
||||
#endif /* USE_PAM */
|
||||
#endif /* ACCT_TOOLS_SETUID */
|
||||
|
||||
#include "alloc.h"
|
||||
#include "chkname.h"
|
||||
#include "defines.h"
|
||||
#include "groupio.h"
|
||||
@@ -249,7 +251,7 @@ static void grp_update (void)
|
||||
// requested to replace the existing groups
|
||||
if (NULL != grp.gr_mem[0])
|
||||
gr_free_members(&grp);
|
||||
grp.gr_mem = (char **)xmalloc(sizeof(char *));
|
||||
grp.gr_mem = XMALLOC(char *);
|
||||
grp.gr_mem[0] = NULL;
|
||||
} else {
|
||||
// append to existing groups
|
||||
@@ -557,15 +559,15 @@ static void prepare_failure_reports (void)
|
||||
#endif
|
||||
info_passwd.name = group_name;
|
||||
|
||||
gr = xmalloc (512);
|
||||
gr = XMALLOCARRAY(512, char);
|
||||
info_group.audit_msg = gr;
|
||||
gr_end = gr + 512;
|
||||
#ifdef SHADOWGRP
|
||||
sgr = xmalloc (512);
|
||||
sgr = XMALLOCARRAY(512, char);
|
||||
info_gshadow.audit_msg = sgr;
|
||||
sgr_end = sgr + 512;
|
||||
#endif
|
||||
pw = xmalloc (512);
|
||||
pw = XMALLOCARRAY(512, char);
|
||||
info_passwd.audit_msg = pw;
|
||||
pw_end = pw + 512;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user