From owner-freebsd-ports-bugs@FreeBSD.ORG Thu Jul 3 09:37:43 2003 Return-Path: Delivered-To: freebsd-ports-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 408F137B401; Thu, 3 Jul 2003 09:37:43 -0700 (PDT) Received: from atlas.informatik.rwth-aachen.de (atlas.Informatik.RWTH-Aachen.DE [137.226.194.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8033D43FE1; Thu, 3 Jul 2003 09:37:41 -0700 (PDT) (envelope-from stolz@i2.informatik.rwth-aachen.de) Received: from menelaos.informatik.rwth-aachen.de (menelaos.Informatik.RWTH-Aachen.DE [137.226.194.73]) 8.11.1-0.5) with ESMTP id h63GbeK15115; Thu, 3 Jul 2003 18:37:40 +0200 Received: (from stolz@localhost)h63GbeTp040192; Thu, 3 Jul 2003 18:37:40 +0200 (CEST) (envelope-from stolz) Date: Thu, 3 Jul 2003 18:37:40 +0200 From: Volker Stolz To: "Sergey A. Osokin" Message-ID: <20030703163740.GA39180@i2.informatik.rwth-aachen.de> References: <200307031330.h63DUUsM044221@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="opJtzjQTFsWo+cga" Content-Disposition: inline In-Reply-To: <200307031330.h63DUUsM044221@freefall.freebsd.org> X-PGP-Key: finger vs@foldr.org X-PGP-Id: 0x3FD1B6B5 User-Agent: Mutt/1.5.3i cc: freebsd-ports-bugs@FreeBSD.org Subject: Re: ports/54012: [patch] devel/mk: Update to 1.4 X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jul 2003 16:37:43 -0000 --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 03, 2003 at 06:30:30AM -0700, Sergey A. Osokin wrote: > Synopsis: [patch] devel/mk: Update to 1.4 > > What do you think about fix the following: > /usr/home/osa/src/mk/work/mk-1.4/src/Posix.c:285: > warning: tmpnam() possibly used unsafely; consider using mkstemp() Try the attached patch. IANAE, but should/seems to work. BTW: The previous versions had tmpnam() as well, so it might not strictly be necessary to fix it. Volker -- http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME rage against the finite state machine --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch-mkstemp --- src/main.c.orig Wed Jun 5 17:30:39 2002 +++ src/main.c Thu Jul 3 18:34:19 2003 @@ -33,7 +33,7 @@ main(int argc, char **argv) { Word *w; - char *s, *temp; + char *s; char *files[256], **f = files, **ff; int sflag = 0; int i; @@ -41,6 +41,8 @@ Biobuf tb; Bufblock *buf; Bufblock *whatif; + char TMPLATE[14]; + (void)strncpy(TMPLATE,"/tmp/mk.XXXXX", sizeof(TMPLATE)); /* * start with a copy of the current environment variables @@ -133,21 +135,15 @@ /* assignment args become null strings */ - temp = 0; for(i = 0; argv[i]; i++) if(utfrune(argv[i], '=')){ bufcpy(buf, argv[i], strlen(argv[i])); insert(buf, ' '); if(tfd < 0){ - temp = maketmp(); - if(temp == 0) { - perror("temp file"); - Exit(); - } - close(create(temp, OWRITE, 0600)); - if((tfd = open(temp, 2)) < 0){ - perror(temp); + if ((tfd = mkstemp(TMPLATE)) < 0){ + perror(TMPLATE); Exit(); } + unlink(TMPLATE); Binit(&tb, tfd, OWRITE); } Bprint(&tb, "%s\n", argv[i]); @@ -157,7 +153,6 @@ Bflush(&tb); LSEEK(tfd, 0L, 0); parse("command line args", tfd, 1); - remove(temp); } if (buf->current != buf->start) { --- src/Posix.c.orig Thu Jul 3 16:08:16 2003 +++ src/Posix.c Thu Jul 3 16:08:31 2003 @@ -276,14 +276,6 @@ signal(sigmsgs[i].sig, notifyf); } -char* -maketmp(void) -{ - static char temp[L_tmpnam]; - - return tmpnam(temp); -} - int chgtime(char *name) { --opJtzjQTFsWo+cga--