FreeBSD Bugzilla – Attachment 104458 Details for
Bug 144644
[patch] Fix *alloc cornercases with config(1)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
config-failure-corner-cases.diff.txt
config-failure-corner-cases.diff.txt (text/plain; charset=US-ASCII), 4.51 KB, created by
Enji Cooper
on 2010-03-13 07:36:52 UTC
(
hide
)
Description:
config-failure-corner-cases.diff.txt
Filename:
MIME Type:
Creator:
Enji Cooper
Created:
2010-03-13 07:36:52 UTC
Size:
4.51 KB
patch
obsolete
>Index: mkoptions.c >=================================================================== >--- mkoptions.c (revision 205115) >+++ mkoptions.c (working copy) >@@ -70,6 +70,8 @@ > /* Fake the cpu types as options. */ > SLIST_FOREACH(cp, &cputype, cpu_next) { > op = (struct opt *)calloc(1, sizeof(*op)); >+ if (op == NULL) >+ errx(EXIT_FAILURE, "calloc"); > op->op_name = ns(cp->cpu_name); > SLIST_INSERT_HEAD(&opt, op, op_next); > } >@@ -84,6 +86,8 @@ > > /* Fake MAXUSERS as an option. */ > op = (struct opt *)calloc(1, sizeof(*op)); >+ if (op == NULL) >+ errx(EXIT_FAILURE, "calloc"); > op->op_name = ns("MAXUSERS"); > snprintf(buf, sizeof(buf), "%d", maxusers); > op->op_value = ns(buf); >@@ -199,6 +203,8 @@ > tidy++; > } else { > op = (struct opt *) calloc(1, sizeof *op); >+ if (op == NULL) >+ errx(EXIT_FAILURE, "calloc"); > op->op_name = inw; > op->op_value = invalue; > SLIST_INSERT_HEAD(&op_head, op, op_next); >@@ -225,6 +231,8 @@ > if (value && !seen) { > /* New option appears */ > op = (struct opt *) calloc(1, sizeof *op); >+ if (op == NULL) >+ errx(EXIT_FAILURE, "calloc"); > op->op_name = ns(name); > op->op_value = value ? ns(value) : NULL; > SLIST_INSERT_HEAD(&op_head, op, op_next); >@@ -336,6 +344,8 @@ > } > > po = (struct opt_list *) calloc(1, sizeof *po); >+ if (po == NULL) >+ errx(EXIT_FAILURE, "calloc"); > po->o_name = this; > po->o_file = val; > SLIST_INSERT_HEAD(&otab, po, o_next); >Index: main.c >=================================================================== >--- main.c (revision 205115) >+++ main.c (working copy) >@@ -120,7 +120,7 @@ > if (*destdir == '\0') > strlcpy(destdir, optarg, sizeof(destdir)); > else >- errx(2, "directory already set"); >+ errx(EXIT_FAILURE, "directory already set"); > break; > case 'g': > debugging++; >@@ -175,7 +175,7 @@ > if (mkdir(p, 0777)) > err(2, "%s", p); > } else if (!S_ISDIR(buf.st_mode)) >- errx(2, "%s isn't a directory", p); >+ errx(EXIT_FAILURE, "%s isn't a directory", p); > > SLIST_INIT(&cputype); > SLIST_INIT(&mkopt); >@@ -256,7 +256,7 @@ > int i; > > if (realpath("../..", srcdir) == NULL) >- errx(2, "Unable to find root of source tree"); >+ errx(EXIT_FAILURE, "Unable to find root of source tree"); > if ((pwd = getenv("PWD")) != NULL && *pwd == '/' && > (pwd = strdup(pwd)) != NULL) { > /* Remove the last two path components. */ >@@ -650,6 +650,8 @@ > } > } > hl = calloc(1, sizeof(*hl)); >+ if (hl == NULL) >+ errx(EXIT_FAILURE, "calloc"); > hl->h_name = s; > hl->h_next = htab; > htab = hl; >Index: mkmakefile.c >=================================================================== >--- mkmakefile.c (revision 205115) >+++ mkmakefile.c (working copy) >@@ -98,6 +98,8 @@ > struct file_list *fp; > > fp = (struct file_list *) calloc(1, sizeof *fp); >+ if (fp == NULL) >+ errx(EXIT_FAILURE, "calloc"); > STAILQ_INSERT_TAIL(&ftab, fp, f_next); > return (fp); > } >Index: lang.l >=================================================================== >--- lang.l (revision 205115) >+++ lang.l (working copy) >@@ -31,6 +31,7 @@ > * $FreeBSD$ > */ > >+#include <err.h> > #include <assert.h> > #include <ctype.h> > #include <string.h> >@@ -220,6 +221,8 @@ > struct cfgfile *cf; > > cf = calloc(1, sizeof(*cf)); >+ if (cf == NULL) >+ errx(EXIT_FAILURE, "calloc"); > assert(cf != NULL); > asprintf(&cf->cfg_path, "%s", fname); > STAILQ_INSERT_TAIL(&cfgfiles, cf, cfg_next); >Index: config.y >=================================================================== >--- config.y (revision 205115) >+++ config.y (working copy) >@@ -166,6 +166,8 @@ > CPU Save_id { > struct cputype *cp = > (struct cputype *)calloc(1, sizeof (struct cputype)); >+ if (cp == NULL) >+ errx(EXIT_FAILURE, "calloc"); > cp->cpu_name = $2; > SLIST_INSERT_HEAD(&cputype, cp, cpu_next); > } | >@@ -197,6 +199,8 @@ > struct hint *hint; > > hint = (struct hint *)calloc(1, sizeof (struct hint)); >+ if (hint == NULL) >+ errx(EXIT_FAILURE, "calloc"); > hint->hint_name = $2; > STAILQ_INSERT_TAIL(&hints, hint, hint_next); > hintmode = 1; >@@ -331,6 +335,8 @@ > struct files_name *nl; > > nl = (struct files_name *) calloc(1, sizeof *nl); >+ if (nl == NULL) >+ errx(EXIT_FAILURE, "calloc"); > nl->f_name = name; > STAILQ_INSERT_TAIL(&fntab, nl, f_next); > } >@@ -364,6 +370,8 @@ > } > > np = (struct device *) calloc(1, sizeof *np); >+ if (np == NULL) >+ errx(EXIT_FAILURE, "calloc"); > np->d_name = name; > STAILQ_INSERT_TAIL(&dtab, np, d_next); > } >@@ -422,6 +430,8 @@ > } > > op = (struct opt *)calloc(1, sizeof (struct opt)); >+ if (op == NULL) >+ errx(EXIT_FAILURE, "calloc"); > op->op_name = name; > op->op_ownfile = 0; > op->op_value = value;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 144644
:
104456
|
104457
| 104458 |
104459
|
104460