Article View: comp.sources.bugs
Article #161A bug in perl3 (mkdir). A quick fix.
From: Michael Greim
Date: Tue, 12 Sep 1989 13:08
Date: Tue, 12 Sep 1989 13:08
78 lines
2702 bytes
2702 bytes
This is a bug report and quick fix to help people fix perl until
Larry Wall issues an official patch. I have sent this also to Larry
Wall.
-mg
Bug in perl3.
Priority: medium
Symptoms:
The test op.mkdir fails.
If perl tries to "mkdir" a directory which already exists, it thinks
the operation did succeed, although it failed.
Diagnosis:
The machine has no library function (system call) mkdir. So perl
tries to emulate the call by forking off the program /bin/mkdir.
It then reads the output from this command and decides whether
it succeeded or not by :
- if there is no text, it succeeded
- if there is text, examine it. What error message was it? Set
errno accordingly.
On the machine on which I found this bug, mkdir returns status 1 and
a text which is not a valid error message. Thus the error message
was not found, and the return-value for mkdir was not set.
Below is the relevant code from eval.c
Add the line marked by "mg".
(Sorry: no context diffs, I have changed the lines by adding test output)
-------- cut here ---------
case O_MKDIR:
tmps = str_get(st[1]);
anum = (int)str_gnum(st[2]);
#ifdef TAINT
taintproper("Insecure dependency in mkdir");
#endif
#ifdef MKDIR
value = (double)(mkdir(tmps,anum) >= 0);
#else
(void)sprintf(buf,"mkdir %s 2>&1",tmps);
one_liner:
rsfp = mypopen(buf,"r");
if (rsfp) {
*buf = '\0';
tmps2 = fgets(buf,sizeof buf,rsfp);
(void)mypclose(rsfp);
if (tmps2 != Nullch) {
for (errno = 1; errno <= sys_nerr; errno++) {
if (instr(buf,sys_errlist[errno])) /* you don't see this */
goto say_zero;
}
errno = 0;
goto say_zero; /* mg, 11-sep-89 Note: errno is not set correctly */
}
else
value = 1.0;
}
else
goto say_zero;
#endif
goto donumset;
case O_RMDIR:
-------- cut here ---------
The value of errno is not set correctly. What should the
correct value be ???
Absorb, apply and enjoy,
-mg
--
Michael Greim Email : greim@sbsvax.informatik.uni-saarland.dbp.de
or : ...!uunet!unido!sbsvax!greim
[.signature removed by the board of censors for electronic mail's main
executive computer because it contained a four letter word ("word")]
Technical Details
Message-ID:
<857@sbsvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcsun!unido!sbsvax!greimShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcsun!unido!sbsvax!greim From: greim@sbsvax.UUCP (Michael Greim) Newsgroups: comp.sources.bugs Subject: A bug in perl3 (mkdir). A quick fix. Keywords: perl3 bug fix mkdir Message-ID: <857@sbsvax.UUCP> Date: 12 Sep 89 13:08:17 GMT Organization: Universitaet des Saarlandes, Saarbruecken, W-Germany Lines: 78