Date: Sun, 9 May 2010 07:29:31 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 177990 for review Message-ID: <201005090729.o497TVeA046213@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@177990?ac=10 Change 177990 by gcooper@gcooper-bayonetta on 2010/05/09 07:28:42 Resolve the full path to all path related arguments so that we won't need to use copy_file. Affected files ... .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/create/main.c#5 edit Differences ... ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/create/main.c#5 (text+ko) ==== @@ -12,9 +12,11 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD: src/usr.sbin/pkg_install/create/main.c,v 1.48 2010/04/23 11:07:43 flz Exp $"); +#include <sys/param.h> #include <err.h> #include <getopt.h> #include <libgen.h> +#include <stdlib.h> #include <pkg.h> #include "create.h" @@ -68,6 +70,12 @@ { NULL, 0, NULL, 0 }, }; +#define RESOLVE_PATH(v, path) \ + do { \ + if ((v = malloc(PATH_MAX)) == NULL || realpath(path, v) == NULL)\ + err(EXIT_FAILURE, "couldn't resolve path for %s", path);\ + } while (0) + int main(int argc, char **argv) { @@ -110,7 +118,7 @@ break; case 'p': - Prefix = optarg; + RESOLVE_PATH(Prefix, optarg); break; case 's': @@ -122,7 +130,7 @@ break; case 'f': - Contents = optarg; + RESOLVE_PATH(Contents, optarg); break; case 'C': @@ -130,39 +138,40 @@ break; case 'c': - Comment = optarg; + RESOLVE_PATH(Comment, optarg); break; case 'd': - Desc = optarg; + RESOLVE_PATH(Desc, optarg); break; case 'i': - Install = optarg; + RESOLVE_PATH(Install, optarg); break; case 'I': - PostInstall = optarg; + RESOLVE_PATH(PostInstall, optarg); break; case 'k': - DeInstall = optarg; + RESOLVE_PATH(DeInstall, optarg); break; case 'K': - PostDeInstall = optarg; + RESOLVE_PATH(PostDeInstall, optarg); break; case 'r': - Require = optarg; + RESOLVE_PATH(Require, optarg); break; case 't': - strlcpy(PlayPen, optarg, sizeof(PlayPen)); + if (strlcpy(PlayPen, optarg, sizeof(PlayPen)) > sizeof(PlayPen)) + errx(EXIT_FAILURE, "Playpen template specified invalid"); break; case 'X': - ExcludeFrom = optarg; + RESOLVE_PATH(ExcludeFrom, optarg); break; case 'h': @@ -170,11 +179,11 @@ break; case 'D': - Display = optarg; + RESOLVE_PATH(Display, optarg); break; case 'm': - Mtree = optarg; + RESOLVE_PATH(Mtree, optarg); break; case 'P':
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005090729.o497TVeA046213>