diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-05-14 10:53:55 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-05-14 10:53:55 +0000 |
commit | 20408e3ccf502b6ce4033d8203710405ec9ef8f6 (patch) | |
tree | afa7181c847061200a7323363f84fe42102c2aa3 /doio.c | |
parent | 9b599b2a63d2324ddacddd9710c41b795a95070d (diff) | |
download | perl-20408e3ccf502b6ce4033d8203710405ec9ef8f6.tar.gz |
[win32] merge change#896 from maintbranch
p4raw-link: @896 on //depot/maint-5.004/perl: 0562b9ae2b0eff79632fc0164c13c34c06a019e2
p4raw-id: //depot/win32/perl@938
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 65 |
1 files changed, 50 insertions, 15 deletions
@@ -583,6 +583,7 @@ do_close(GV *gv, bool not_implicit) if (!io) { /* never opened */ if (dowarn && not_implicit) warn("Close on unopened file <%s>",GvENAME(gv)); + SETERRNO(EBADF,SS$_IVCHAN); return FALSE; } retval = io_close(io); @@ -619,6 +620,9 @@ io_close(IO *io) } IoOFP(io) = IoIFP(io) = Nullfp; } + else { + SETERRNO(EBADF,SS$_IVCHAN); + } return retval; } @@ -1033,9 +1037,14 @@ apply(I32 type, register SV **mark, register SV **sp) register I32 val; register I32 val2; register I32 tot = 0; + char *what; char *s; SV **oldmark = mark; +#define APPLY_TAINT_PROPER() \ + if (!(tainting && tainted)) {} else { goto taint_proper; } + + /* This is a first heuristic; it doesn't catch tainting magic. */ if (tainting) { while (++mark <= sp) { if (SvTAINTED(*mark)) { @@ -1047,25 +1056,33 @@ apply(I32 type, register SV **mark, register SV **sp) } switch (type) { case OP_CHMOD: - TAINT_PROPER("chmod"); + what = "chmod"; + APPLY_TAINT_PROPER(); if (++mark <= sp) { - tot = sp - mark; val = SvIVx(*mark); + APPLY_TAINT_PROPER(); + tot = sp - mark; while (++mark <= sp) { - if (PerlLIO_chmod(SvPVx(*mark, na),val)) + char *name = SvPVx(*mark, na); + APPLY_TAINT_PROPER(); + if (PerlLIO_chmod(name, val)) tot--; } } break; #ifdef HAS_CHOWN case OP_CHOWN: - TAINT_PROPER("chown"); + what = "chown"; + APPLY_TAINT_PROPER(); if (sp - mark > 2) { val = SvIVx(*++mark); val2 = SvIVx(*++mark); + APPLY_TAINT_PROPER(); tot = sp - mark; while (++mark <= sp) { - if (chown(SvPVx(*mark, na),val,val2)) + char *name = SvPVx(*mark, na); + APPLY_TAINT_PROPER(); + if (chown(name, val, val2)) tot--; } } @@ -1073,11 +1090,11 @@ apply(I32 type, register SV **mark, register SV **sp) #endif #ifdef HAS_KILL case OP_KILL: - TAINT_PROPER("kill"); + what = "kill"; + APPLY_TAINT_PROPER(); if (mark == sp) break; s = SvPVx(*++mark, na); - tot = sp - mark; if (isUPPER(*s)) { if (*s == 'S' && s[1] == 'I' && s[2] == 'G') s += 3; @@ -1086,6 +1103,8 @@ apply(I32 type, register SV **mark, register SV **sp) } else val = SvIVx(*mark); + APPLY_TAINT_PROPER(); + tot = sp - mark; #ifdef VMS /* kill() doesn't do process groups (job trees?) under VMS */ if (val < 0) val = -val; @@ -1098,6 +1117,7 @@ apply(I32 type, register SV **mark, register SV **sp) while (++mark <= sp) { I32 proc = SvIVx(*mark); register unsigned long int __vmssts; + APPLY_TAINT_PROPER(); if (!((__vmssts = sys$delprc(&proc,0)) & 1)) { tot--; switch (__vmssts) { @@ -1120,6 +1140,7 @@ apply(I32 type, register SV **mark, register SV **sp) val = -val; while (++mark <= sp) { I32 proc = SvIVx(*mark); + APPLY_TAINT_PROPER(); #ifdef HAS_KILLPG if (PerlProc_killpg(proc,val)) /* BSD */ #else @@ -1130,17 +1151,21 @@ apply(I32 type, register SV **mark, register SV **sp) } else { while (++mark <= sp) { - if (PerlProc_kill(SvIVx(*mark),val)) + I32 proc = SvIVx(*mark); + APPLY_TAINT_PROPER(); + if (PerlProc_kill(proc, val)) tot--; } } break; #endif case OP_UNLINK: - TAINT_PROPER("unlink"); + what = "unlink"; + APPLY_TAINT_PROPER(); tot = sp - mark; while (++mark <= sp) { s = SvPVx(*mark, na); + APPLY_TAINT_PROPER(); if (euid || unsafe) { if (UNLINK(s)) tot--; @@ -1161,7 +1186,8 @@ apply(I32 type, register SV **mark, register SV **sp) break; #ifdef HAS_UTIME case OP_UTIME: - TAINT_PROPER("utime"); + what = "utime"; + APPLY_TAINT_PROPER(); if (sp - mark > 2) { #if defined(I_UTIME) || defined(VMS) struct utimbuf utbuf; @@ -1180,9 +1206,12 @@ apply(I32 type, register SV **mark, register SV **sp) utbuf.actime = SvIVx(*++mark); /* time accessed */ utbuf.modtime = SvIVx(*++mark); /* time modified */ #endif + APPLY_TAINT_PROPER(); tot = sp - mark; while (++mark <= sp) { - if (PerlLIO_utime(SvPVx(*mark, na),&utbuf)) + char *name = SvPVx(*mark, na); + APPLY_TAINT_PROPER(); + if (PerlLIO_utime(name, &utbuf)) tot--; } } @@ -1192,6 +1221,12 @@ apply(I32 type, register SV **mark, register SV **sp) #endif } return tot; + + taint_proper: + TAINT_PROPER(what); + return 0; /* this should never happen */ + +#undef APPLY_TAINT_PROPER } /* Do the permissions allow some operation? Assumes statcache already set. */ @@ -1305,7 +1340,7 @@ do_ipcget(I32 optype, SV **mark, SV **sp) return -1; /* should never happen */ } -#if defined(__sun__) && defined(__svr4__) /* XXX Need metaconfig test */ +#if defined(__sun) && defined(__svr4__) /* XXX Need metaconfig test */ /* Solaris manpage says that it uses (like linux) int semctl (int semid, int semnum, int cmd, union semun arg) but the system include files do not define union semun !!!! @@ -1325,7 +1360,7 @@ do_ipcctl(I32 optype, SV **mark, SV **sp) char *a; I32 id, n, cmd, infosize, getinfo; I32 ret = -1; -#if defined(__linux__) || (defined(__sun__) && defined(__svr4__)) +#if defined(__linux__) || (defined(__sun) && defined(__svr4__)) /* XXX Need metaconfig test */ union semun unsemds; #endif @@ -1358,7 +1393,7 @@ do_ipcctl(I32 optype, SV **mark, SV **sp) else if (cmd == GETALL || cmd == SETALL) { struct semid_ds semds; -#if defined(__linux__) || (defined(__sun__) && defined(__svr4__)) +#if defined(__linux__) || (defined(__sun) && defined(__svr4__)) /* XXX Need metaconfig test */ /* linux and Solaris2 uses : int semctl (int semid, int semnum, int cmd, union semun arg) @@ -1419,7 +1454,7 @@ do_ipcctl(I32 optype, SV **mark, SV **sp) #endif #ifdef HAS_SEM case OP_SEMCTL: -#if defined(__linux__) || (defined(__sun__) && defined(__svr4__)) +#if defined(__linux__) || (defined(__sun) && defined(__svr4__)) /* XXX Need metaconfig test */ unsemds.buf = (struct semid_ds *)a; ret = semctl(id, n, cmd, unsemds); |