From owner-freebsd-bugs Sun Sep 21 14:20:07 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id OAA17399 for bugs-outgoing; Sun, 21 Sep 1997 14:20:07 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.7/8.8.7) id OAA17393; Sun, 21 Sep 1997 14:20:03 -0700 (PDT) Resent-Date: Sun, 21 Sep 1997 14:20:03 -0700 (PDT) Resent-Message-Id: <199709212120.OAA17393@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, hsu@mail.clinet.fi Received: from hauki.clinet.fi (root@hauki.clinet.fi [194.100.0.1]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id OAA17063 for ; Sun, 21 Sep 1997 14:11:16 -0700 (PDT) Received: from katiska.clinet.fi (root@katiska.clinet.fi [194.100.0.4]) by hauki.clinet.fi (8.8.6/8.8.6) with ESMTP id AAA07784 for ; Mon, 22 Sep 1997 00:10:53 +0300 (EET DST) Received: (root@localhost) by katiska.clinet.fi (8.8.7/8.6.4) id AAA14120; Mon, 22 Sep 1997 00:10:53 +0300 (EEST) Message-Id: <199709212110.AAA14120@katiska.clinet.fi> Date: Mon, 22 Sep 1997 00:10:53 +0300 (EEST) From: Heikki Suonsivu Reply-To: hsu@mail.clinet.fi To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/4599: mktemp is too smart, accesses the path given Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 4599 >Category: bin >Synopsis: mktemp is too smart, accesses the path given >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Sep 21 14:20:01 PDT 1997 >Last-Modified: >Originator: Heikki Suonsivu >Organization: Clinet, Espoo, Finland >Release: FreeBSD 2.2-STABLE i386 >Environment: FreeBSD, I think in all versions from at least 2.2. >Description: mktemp is supposed to randomize a given pathname by replacing X's in the given string with process-specific numbers/data. However, if the given string does not point to a valid path, it returns NULL and botches the argument string. As it is supposed just to create a path name, this should not happen ? This breaks rdist6, which wants to create a temporary path and patch up missing directories on the path afterwards. >How-To-Repeat: #include #include main() { char foo[1024]; strcpy(foo, "/some/unexistent/directoryXXXXXX"); if (!mktemp(foo)) { perror(foo); } printf("foo become %s\n", foo); } hsu#katiska.clinet.fi Sun 10: ./hello /some/unexistent: No such file or directory foo become /some/unexistent hsu#katiska.clinet.fi Sun 11: >Fix: Dirty workaround for rdist6 (server.c): #if 0 if (!mktemp(new)) { error("Cannot create temporary name, errno %d.", errno); } #else { char *p; p = strstr(new, "XXXXXX"); if (p) sprintf(p, "%6d", getpid() % 1000000); else error("Cannot create temporary name"); } #endif -- Heikki Suonsivu, T{ysikuu 10 C 83/02210 Espoo/FINLAND, hsu@clinet.fi mobile +358-40-5519679 work +358-9-43542270 fax -4555276 >Audit-Trail: >Unformatted: