From: Ben Collins Date: Tue, 19 Oct 1999 14:42:23 +0000 (+0000) Subject: * Reverted the new tmpfile stuff in dpkg-deb. For some reason it's X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3593fd4559c9f3012d95b79aee4ed7c3d9ff2d16;p=dpkg * Reverted the new tmpfile stuff in dpkg-deb. For some reason it's completely corrupting the new package --- diff --git a/ChangeLog b/ChangeLog index 8b1ba574..b12d6460 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Oct 19 09:59:22 EDT 1999 Ben Collins + + * Reverted the new tmpfile stuff in dpkg-deb. For some reason it's + completely corrupting the new package + Mon Oct 18 18:40:35 EDT 1999 Ben Collins * Reimplemented a better *stat cache for the removal checking code, diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index e7d834d3..d02ae0e8 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -57,13 +57,13 @@ void do_build(const char *const *argv) { PREINSTFILE, POSTINSTFILE, PRERMFILE, POSTRMFILE, 0 }; - char *m, *tmpd, *tmpf; + char *m; const char *debar, *directory, *const *mscriptp, *versionstring, *arch; char *controlfile; struct pkginfo *checkedinfo; struct arbitraryfield *field; FILE *ar, *gz, *cf; - int p1[2],p2[2], warns, errs, n, c, subdir, gzfd; + int p1[2],p2[2], warns, errs, n, c, subdir; pid_t c1,c2,c3,c4,c5; struct stat controlstab, datastab, mscriptstab, debarstab; char conffilename[MAXCONFFILENAME+1]; @@ -209,16 +209,7 @@ void do_build(const char *const *argv) { execlp(TAR,"tar","-cf","-",".",(char*)0); ohshite(_("failed to exec tar -cf")); } close(p1[1]); - - if (!(tmpd = getenv("TMPDIR"))) - tmpd= "/tmp"; - tmpf= malloc(strlen(tmpd) + strlen("/dpkg.XXXXXX")); - strcpy(tmpf, tmpd); - strcat(tmpf, "/dpkg.XXXXXX"); - if (!(gzfd= mkstemp(tmpf)) || !(gz= fdopen(gzfd, "r+"))) - ohshite(_("failed to make tmpfile (control)")); - - + if (!(gz= tmpfile())) ohshite(_("failed to make tmpfile (control)")); if (!(c2= m_fork())) { m_dup2(p1[0],0); m_dup2(fileno(gz),1); close(p1[0]); execlp(GZIP,"gzip","-9c",(char*)0); ohshite(_("failed to exec gzip -9c")); @@ -255,12 +246,8 @@ void do_build(const char *const *argv) { if (!oldformatflag) { fclose(gz); - strcpy(tmpf, tmpd); - strcat(tmpf, "/dpkg.XXXXXX"); - if (!(gzfd= mkstemp(tmpf)) || !(gz= fdopen(gzfd, "r+"))) - ohshite(_("failed to make tmpfile (data)")); + if (!(gz= tmpfile())) ohshite(_("failed to make tmpfile (data)")); } - free(tmpf); m_pipe(p2); if (!(c4= m_fork())) { m_dup2(p2[1],1); close(p2[0]); close(p2[1]); diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c index f258879c..438d76fd 100644 --- a/dpkg-deb/info.c +++ b/dpkg-deb/info.c @@ -59,13 +59,12 @@ static void info_prepare(const char *const **argvp, const char **debarp, const char **directoryp, int admininfo) { - char *dbuf; + static char dbuf[L_tmpnam]; pid_t c1; *debarp= *(*argvp)++; if (!*debarp) badusage(_("--%s needs a .deb filename argument"),cipaction->olong); - dbuf = tempnam(NULL, "dpkg"); - if (!dbuf) ohshite(_("failed to make temporary filename")); + if (!tmpnam(dbuf)) ohshite(_("failed to make temporary filename")); *directoryp= dbuf; if (!(c1= m_fork())) { @@ -74,7 +73,6 @@ static void info_prepare(const char *const **argvp, waitsubproc(c1,"rm -rf",0); push_cleanup(cu_info_prepare,-1, 0,0, 1, (void*)dbuf); extracthalf(*debarp, dbuf, "mx", admininfo); - free(dbuf); } static int ilist_select(const struct dirent *de) {