Wait for popen() to finish before passing to isSpecFile()
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 4 Apr 2008 11:33:45 +0000 (14:33 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 4 Apr 2008 11:41:40 +0000 (14:41 +0300)
build.c

diff --git a/build.c b/build.c
index 1799955..f00e98d 100644 (file)
--- a/build.c
+++ b/build.c
@@ -136,9 +136,9 @@ static char * getTarSpec(const char *arg)
        if (!(fp = popen(cmd, "r"))) {
            rpmlog(RPMLOG_ERR, _("Failed to open tar pipe: %m\n"));
        } else {
-           gotspec = fgets(tarbuf, sizeof(tarbuf) - 1, fp) && 
-                       isSpecFile(tmpSpecFile);
+           char *fok = fgets(tarbuf, sizeof(tarbuf) - 1, fp);
            pclose(fp);
+           gotspec = (fok != NULL) && isSpecFile(tmpSpecFile);
        }
 
        if (!gotspec)