svn commit: r302969 - stable/9/usr.bin/mail
Pedro F. Giffuni
pfg at FreeBSD.org
Sun Jul 17 18:33:19 UTC 2016
Author: pfg
Date: Sun Jul 17 18:33:17 2016
New Revision: 302969
URL: https://svnweb.freebsd.org/changeset/base/302969
Log:
MFC r302511, r302771, r302845:
mail(1): check for out of memory conditions when calling calloc(3).
Modified:
stable/9/usr.bin/mail/cmd3.c
stable/9/usr.bin/mail/vars.c
Directory Properties:
stable/9/usr.bin/mail/ (props changed)
Modified: stable/9/usr.bin/mail/cmd3.c
==============================================================================
--- stable/9/usr.bin/mail/cmd3.c Sun Jul 17 18:32:33 2016 (r302968)
+++ stable/9/usr.bin/mail/cmd3.c Sun Jul 17 18:33:17 2016 (r302969)
@@ -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);
Modified: stable/9/usr.bin/mail/vars.c
==============================================================================
--- stable/9/usr.bin/mail/vars.c Sun Jul 17 18:32:33 2016 (r302968)
+++ stable/9/usr.bin/mail/vars.c Sun Jul 17 18:33:17 2016 (r302969)
@@ -56,7 +56,8 @@ assign(const char *name, const char *val
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;
More information about the svn-src-stable-9
mailing list