summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-07-17 18:32:33 +0000
committerpfg <pfg@FreeBSD.org>2016-07-17 18:32:33 +0000
commit598789d2553d5a4307cfb8f94f252e1f3193e2e5 (patch)
treeaa7ee20b8a88f77d5d42b2b5311889d18e26979a /usr.bin
parent98960de4ab0561ab3ca3ee2e1bb5cc8657d28b60 (diff)
downloadFreeBSD-src-598789d2553d5a4307cfb8f94f252e1f3193e2e5.zip
FreeBSD-src-598789d2553d5a4307cfb8f94f252e1f3193e2e5.tar.gz
MFC r302511, r302771, r302845:
mail(1): check for out of memory conditions when calling calloc(3).
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mail/cmd3.c9
-rw-r--r--usr.bin/mail/vars.c3
2 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/mail/cmd3.c b/usr.bin/mail/cmd3.c
index 9308ad3..11954d1 100644
--- a/usr.bin/mail/cmd3.c
+++ b/usr.bin/mail/cmd3.c
@@ -463,7 +463,8 @@ group(char **argv)
gname = *argv;
h = hash(gname);
if ((gh = findgroup(gname)) == NULL) {
- gh = calloc(sizeof(*gh), 1);
+ if ((gh = calloc(1, sizeof(*gh))) == NULL)
+ err(1, "Out of memory");
gh->g_name = vcopy(gname);
gh->g_list = NULL;
gh->g_link = groups[h];
@@ -477,7 +478,8 @@ group(char **argv)
*/
for (ap = argv+1; *ap != NULL; ap++) {
- gp = calloc(sizeof(*gp), 1);
+ if ((gp = calloc(1, sizeof(*gp))) == NULL)
+ err(1, "Out of memory");
gp->ge_name = vcopy(*ap);
gp->ge_link = gh->g_list;
gh->g_list = gp;
@@ -702,7 +704,8 @@ alternates(char **namelist)
}
if (altnames != 0)
(void)free(altnames);
- altnames = calloc((unsigned)c, sizeof(char *));
+ if ((altnames = calloc((unsigned)c, sizeof(char *))) == NULL)
+ err(1, "Out of memory");
for (ap = namelist, ap2 = altnames; *ap != NULL; ap++, ap2++) {
cp = calloc((unsigned)strlen(*ap) + 1, sizeof(char));
strcpy(cp, *ap);
diff --git a/usr.bin/mail/vars.c b/usr.bin/mail/vars.c
index dca0604..f3c6659 100644
--- a/usr.bin/mail/vars.c
+++ b/usr.bin/mail/vars.c
@@ -56,7 +56,8 @@ assign(const char *name, const char *value)
h = hash(name);
vp = lookup(name);
if (vp == NULL) {
- vp = calloc(sizeof(*vp), 1);
+ if ((vp = calloc(1, sizeof(*vp))) == NULL)
+ err(1, "Out of memory");
vp->v_name = vcopy(name);
vp->v_link = variables[h];
variables[h] = vp;
OpenPOWER on IntegriCloud