From owner-freebsd-current Tue Jun 25 2:26:11 2002 Delivered-To: freebsd-current@freebsd.org Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.139.170]) by hub.freebsd.org (Postfix) with ESMTP id A59F537B401 for ; Tue, 25 Jun 2002 02:26:03 -0700 (PDT) Received: from storm.FreeBSD.org.uk (uucp@localhost [127.0.0.1]) by storm.FreeBSD.org.uk (8.12.3/8.12.3) with ESMTP id g5P9Pv8r001647; Tue, 25 Jun 2002 10:25:57 +0100 (BST) (envelope-from mark@grimreaper.grondar.org) Received: (from uucp@localhost) by storm.FreeBSD.org.uk (8.12.3/8.12.3/Submit) with UUCP id g5P9Pvc6001646; Tue, 25 Jun 2002 10:25:57 +0100 (BST) Received: from grimreaper.grondar.org (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.4/8.12.4) with ESMTP id g5P9KJnG005006; Tue, 25 Jun 2002 10:20:19 +0100 (BST) (envelope-from mark@grimreaper.grondar.org) Message-Id: <200206250920.g5P9KJnG005006@grimreaper.grondar.org> To: Jonathan Belson Cc: current@freebsd.org Subject: Re: Perl scripts that need rewiting - Any volunteers? References: <3D17770E.1060904@witchspace.com> In-Reply-To: <3D17770E.1060904@witchspace.com> ; from Jonathan Belson "Mon, 24 Jun 2002 20:46:22 BST." Date: Tue, 25 Jun 2002 10:20:19 +0100 From: Mark Murray Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > o Please shorten any long line or comment to less than 80 columns > > This is quite tricky when using 8 character tabs. Is 4 character indent > okay for userland source? "Real" tabs are best. Look at style(9) for ways to break the long lines. It is ok to break very long lines like this; > > o Please do not use mktemp(); use mkstemp() instead. > > I used mktemp() to get a filename to redirect to, eg. > > /* Improvised example */ > char *cmd; > asprintf(cmd, "prog > %s", mktemp(blah)); > system(cmd); > free(cmd); BIG security hole. Someone can exploit a race to compromise this. > I couldn't see a simple way around this, any clues? How's this? int handle; template = "/tmp/mumbleXXXXXXXX"; char *cmd; handle = mkstemp(template); // template is modified asprintf(cmd, "prog > %s", template); system(cmd); close(handle); // bye-bye file M -- o Mark Murray \_ O.\_ Warning: this .sig is umop ap!sdn To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message