})
-#define XMALLOC(n, T) exit_if_null(malloc_T(n, T))
+// xmalloc_T - exit-on-error malloc type-safe
+#define xmalloc_T(n, T) exit_if_null(malloc_T(n, T))
// mallocarray - malloc array
return NULL;
}
- lp = XMALLOC(1, struct link_name);
+ lp = xmalloc_T(1, struct link_name);
lp->ln_dev = sb->st_dev;
lp->ln_ino = sb->st_ino;
lp->ln_count = sb->st_nlink;
*/
void initenv (void)
{
- newenvp = XMALLOC(NEWENVP_STEP, char *);
+ newenvp = xmalloc_T(NEWENVP_STEP, char *);
*newenvp = NULL;
}
#endif
bufsize = (ULONG_DIGITS + 1) * 3 * ranges + 1;
- pos = buf = XMALLOC(bufsize, char);
+ pos = buf = xmalloc_T(bufsize, char);
end = buf + bufsize;
/* Build the mapping command */
* old entries, and the new entries as well.
*/
- tmp = XMALLOC(i + 2, char *);
+ tmp = xmalloc_T(i + 2, char *);
/*
* Copy the original list to the new list, then append the
* old entries.
*/
- tmp = XMALLOC(j + 1, char *);
+ tmp = xmalloc_T(j + 1, char *);
/*
* Copy the original list except the deleted members to the
for (i = 0; NULL != list[i]; i++);
- tmp = XMALLOC(i + 1, char *);
+ tmp = xmalloc_T(i + 1, char *);
i = 0;
while (NULL != *list) {
*/
n = strchrcnt(members, ',') + 2;
- array = XMALLOC(n, char *);
+ array = xmalloc_T(n, char *);
/*
* Empty list is special - 0 members, not 1 empty member. --marekm
break; /* Perfect match, stop the search */
if (NULL == ut_by_pid) {
- ut_by_pid = XMALLOC(1, struct utmpx);
+ ut_by_pid = xmalloc_T(1, struct utmpx);
*ut_by_pid = *ut;
}
} else if ( (NULL == ut_by_line)
&& (LOGIN_PROCESS == ut->ut_type) /* Be more picky when matching by 'ut_line' only */
&& (is_my_tty(ut->ut_line))) {
- ut_by_line = XMALLOC(1, struct utmpx);
+ ut_by_line = xmalloc_T(1, struct utmpx);
*ut_by_line = *ut;
}
}
if (NULL != ut) {
struct utmpx *ut_copy;
- ut_copy = XMALLOC(1, struct utmpx);
+ ut_copy = xmalloc_T(1, struct utmpx);
memcpy(ut_copy, ut, sizeof(*ut));
ut = ut_copy;
}
sg->sg_mem = dup_list (gr->gr_mem);
- sg->sg_adm = XMALLOC(1, char *);
+ sg->sg_adm = xmalloc_T(1, char *);
sg->sg_adm[0] = NULL;
}
static struct sgrp sgrent;
sgrent.sg_namp = xstrdup (newgrp->gr_name);
sgrent.sg_mem = dup_list (newgrp->gr_mem);
- sgrent.sg_adm = XMALLOC(1, char *);
+ sgrent.sg_adm = xmalloc_T(1, char *);
sgrent.sg_adm[0] = NULL;
/* Move any password to gshadow */
static struct sgrp sgrent;
sgrent.sg_namp = xstrdup (newgrp->gr_name);
sgrent.sg_mem = dup_list (newgrp->gr_mem);
- sgrent.sg_adm = XMALLOC(1, char *);
+ sgrent.sg_adm = xmalloc_T(1, char *);
sgrent.sg_adm[0] = NULL;
/* Move any password to gshadow */
/* Create a shadow group based on this group */
static struct sgrp sgrent;
sgrent.sg_namp = xstrdup (newgrp->gr_name);
- sgrent.sg_mem = XMALLOC(1, char *);
+ sgrent.sg_mem = xmalloc_T(1, char *);
sgrent.sg_mem[0] = NULL;
- sgrent.sg_adm = XMALLOC(1, char *);
+ sgrent.sg_adm = xmalloc_T(1, char *);
sgrent.sg_adm[0] = NULL;
/* Move any password to gshadow */
if (!aflg) {
// requested to replace the existing groups
- grp.gr_mem = XMALLOC(1, char *);
+ grp.gr_mem = xmalloc_T(1, char *);
grp.gr_mem[0] = NULL;
} else {
// append to existing groups
#ifdef SHADOWGRP
if (NULL != osgrp) {
if (!aflg) {
- sgrp.sg_mem = XMALLOC(1, char *);
+ sgrp.sg_mem = xmalloc_T(1, char *);
sgrp.sg_mem[0] = NULL;
} else {
if (NULL != sgrp.sg_mem[0])
#endif
info_passwd.name = group_name;
- gr = XMALLOC(512, char);
+ gr = xmalloc_T(512, char);
info_group.audit_msg = gr;
gr_end = gr + 512;
#ifdef SHADOWGRP
- sgr = XMALLOC(512, char);
+ sgr = xmalloc_T(512, char);
info_gshadow.audit_msg = sgr;
sgr_end = sgr + 512;
#endif
- pw = XMALLOC(512, char);
+ pw = xmalloc_T(512, char);
info_passwd.audit_msg = pw;
pw_end = pw + 512;
exit (1);
}
preauth_flag = false;
- username = XMALLOC(max_size, char);
+ username = xmalloc_T(max_size, char);
login_prompt(username, max_size);
if (streq(username, "")) {
while (NULL != args[n_args]) {
n_args++;
}
- targs = XMALLOC(n_args + 3, char *);
+ targs = xmalloc_T(n_args + 3, char *);
targs[0] = "sh";
targs[1] = "-";
targs[2] = xstrdup (shellname);
#endif
sys_ngroups = sysconf (_SC_NGROUPS_MAX);
- user_groups = XMALLOC(1 + sys_ngroups, char *);
+ user_groups = xmalloc_T(1 + sys_ngroups, char *);
/*
* Initialize the list to be empty
*/
#endif
sys_ngroups = sysconf (_SC_NGROUPS_MAX);
- user_groups = XMALLOC(sys_ngroups + 1, char *);
+ user_groups = xmalloc_T(sys_ngroups + 1, char *);
user_groups[0] = NULL;
is_shadow_pwd = spw_file_present ();
switch (setjmp(jmpb)) {
case 0:
p = "called";
- p = XMALLOC(SIZE_MAX, char);
+ p = xmalloc_T(SIZE_MAX, char);
assert_unreachable();
break;
case EXIT_CALLED:
static const char foo[] = "foo1bar";
- p = XMALLOC(countof(foo), char);
+ p = xmalloc_T(countof(foo), char);
assert_true(p != NULL);
strcpy(p, foo);
assert_string_equal(p, "foo1bar");
free(p);
- p = XMALLOC(0, char);
+ p = xmalloc_T(0, char);
assert_true(p != NULL);
free(p);
}