diff options
author | Brian Fraser <fraserbn@gmail.com> | 2013-05-23 00:44:15 -0300 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2013-06-04 18:45:38 +1000 |
commit | dfff4baff950c3688d6f16335fa1e1037bb84bd0 (patch) | |
tree | 93d04ea7777f2ff99152da88b12a87004fdb8671 /taint.c | |
parent | bcbe2b27bd9868685fb7b4a6158b08674d0387cd (diff) | |
download | perl-dfff4baff950c3688d6f16335fa1e1037bb84bd0.tar.gz |
Stop making assumptions about uids and gids.
The code dealt rather inconsistently with uids and gids. Some
places assumed that they could be safely stored in UVs, others
in IVs, others in ints; All of them should've been using the
macros from config.h instead. Similarly, code that created
SVs or pushed values into the stack was also making incorrect
assumptions -- As a point of reference, only pp_stat did the
right thing:
#if Uid_t_size > IVSIZE
mPUSHn(PL_statcache.st_uid);
#else
# if Uid_t_sign <= 0
mPUSHi(PL_statcache.st_uid);
# else
mPUSHu(PL_statcache.st_uid);
# endif
#endif
The other places were potential bugs, and some were even causing
warnings in some unusual OSs, like haiku or qnx.
This commit ammends the situation by introducing four new macros,
SvUID(), sv_setuid(), SvGID(), and sv_setgid(), and using them
where needed.
Diffstat (limited to 'taint.c')
-rw-r--r-- | taint.c | 17 |
1 files changed, 3 insertions, 14 deletions
@@ -31,25 +31,14 @@ Perl_taint_proper(pTHX_ const char *f, const char *const s) PERL_ARGS_ASSERT_TAINT_PROPER; -# if Uid_t_size == 1 { - const UV uid = PerlProc_getuid(); - const UV euid = PerlProc_geteuid(); + const Uid_t uid = PerlProc_getuid(); + const Uid_t euid = PerlProc_geteuid(); DEBUG_u(PerlIO_printf(Perl_debug_log, - "%s %d %"UVuf" %"UVuf"\n", + "%s %d %"Uid_t_f" %"Uid_t_f"\n", s, TAINT_get, uid, euid)); } -# else - { - const IV uid = PerlProc_getuid(); - const IV euid = PerlProc_geteuid(); - - DEBUG_u(PerlIO_printf(Perl_debug_log, - "%s %d %"IVdf" %"IVdf"\n", - s, TAINT_get, uid, euid)); - } -# endif #endif if (TAINT_get) { |