rpm/getcwdresult.diff

31 lines
848 B
Diff
Raw Normal View History

Check getcwd return value, abort if rpm cannot determine current
directory.
--- ./build.c.orig 2004-10-17 19:00:10.000000000 +0000
+++ ./build.c 2005-12-19 17:52:25.000000000 +0000
@@ -206,7 +211,10 @@ static int buildForTarget(rpmts ts, cons
directory for this run */
if (*arg != '/') {
- (void)getcwd(buf, BUFSIZ);
+ if (!getcwd(buf, BUFSIZ)) {
+ rpmError(RPMERR_STAT, "getcwd failed: %m\n");
+ return 1;
+ }
strcat(buf, "/");
strcat(buf, arg);
} else
@@ -225,7 +233,11 @@ static int buildForTarget(rpmts ts, cons
specut = urlPath(specURL, &specFile);
if (*specFile != '/') {
char *s = alloca(BUFSIZ);
- (void)getcwd(s, BUFSIZ);
+ if (!getcwd(s, BUFSIZ)) {
+ rpmError(RPMERR_STAT, "getcwd failed: %m\n");
+ rc = 1;
+ goto exit;
+ }
strcat(s, "/");
strcat(s, arg);
specURL = s;