diff options
author | Felix Kronlage <fkr@cvs.openbsd.org> | 2009-10-07 13:55:39 +0000 |
---|---|---|
committer | Felix Kronlage <fkr@cvs.openbsd.org> | 2009-10-07 13:55:39 +0000 |
commit | ba9a6940923a3db29f287850f8c06df9b4c16d4b (patch) | |
tree | 6edc99ac485e3fc081caa7e866ba4160ee1cc2e5 /usr.sbin/crunchgen/crunchgen.c | |
parent | 269198f6e486f25aee2c5101a44b5ef20dbcf270 (diff) |
under certain conditions (srcdir defined, no objdir defined) crunchgen
would emit a false .mk file, which contains "(null)" for the Makefile
name due to a null pointer. Make sure, p->mf_name is set in this case.
ok deraadt@
Diffstat (limited to 'usr.sbin/crunchgen/crunchgen.c')
-rw-r--r-- | usr.sbin/crunchgen/crunchgen.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.sbin/crunchgen/crunchgen.c b/usr.sbin/crunchgen/crunchgen.c index 4d53a05b7f8..a79a7539705 100644 --- a/usr.sbin/crunchgen/crunchgen.c +++ b/usr.sbin/crunchgen/crunchgen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crunchgen.c,v 1.4 2008/11/24 17:23:26 drahn Exp $ */ +/* $OpenBSD: crunchgen.c,v 1.5 2009/10/07 13:55:38 fkr Exp $ */ /* * Copyright (c) 1994 University of Maryland @@ -616,6 +616,14 @@ fillin_program(prog_t * p) else p->objdir = p->srcdir; } + /* Fill p->mf_name so it is not a null pointer */ + for (i = 0; mf_name[i] != NULL; i++) { + snprintf(path, sizeof(path), "%s/%s", p->srcdir, mf_name[i]); + if (is_nonempty_file(path)) { + p->mf_name = mf_name[i]; + break; + } + } } /* We have a sourcedir and no explicit objs, try */ /* to find makefile and get objs from it. */ |