summaryrefslogtreecommitdiff
path: root/doio.c
Commit message (Collapse)AuthorAgeFilesLines
* Introduce the double-diamond operator <<>>Rafael Garcia-Suarez2014-09-301-3/+6
| | | | | | | | | | | This operator works like <> or <ARGV>, as it reads the list of file names to open from the command-line arguments. However, it disables the magic-open feature (that forks to execute piped commands) : $ bleadperl -e 'while(<>){print}' 'echo foo |' foo $ bleadperl -e 'while(<<>>){print}' 'echo foo |' Can't open echo foo |: No such file or directory at -e line 1.
* Use grok_atou instead of atoi.Jarkko Hietaniemi2014-07-221-1/+1
| | | | | Remaining atoi() uses include at least: ext/DynaLoader/dl_aix.xs, os2/os2.c, vms/vms.c
* Remove or downgrade unnecessary dVAR.Jarkko Hietaniemi2014-06-251-26/+0
| | | | | | | | You need to configure with g++ *and* -Accflags=-DPERL_GLOBAL_STRUCT or -Accflags=-DPERL_GLOBAL_STRUCT_PRIVATE to see any difference. (g++ does not do the "post-annotation" form of "unused".) The version code has some of these issues, reported upstream.
* Silence -Wunused-parameter my_perl under threads.Jarkko Hietaniemi2014-06-191-0/+6
| | | | | | | | | | | | | | For S_ functions, remove the context. For Perl_ functions, add PERL_UNUSED_CONTEXT. Tricky because sometimes depends on DEBUGGING, and sometimes on whether we are have PERL_IMPLICIT_SYS. (Why all the mathoms Perl_is_uni_... and Perl_is_utf8_... functions are not being whined about is a mystery.) vutil.c (included via util.c) has one of these, but it's cpan/, and a known problem: https://rt.cpan.org/Ticket/Display.html?id=96100
* Adding missing HEKfARG() invocationsBrian Fraser2014-06-131-2/+2
| | | | This silences a chunk of warnings under -Wformat
* 375ed12a broke Config::IniFilesJarkko Hietaniemi2014-06-031-2/+5
| | | | | | | | | ... among other things: https://rt.perl.org/Ticket/Display.html?id=122021 PerlIO::scalar (aka opening scalars for IO) has fileno of -1. This (and probably other exotic PerlIO objects which have funny fds) requires special care.
* Use PERL_UNUSED_RESULT.Jarkko Hietaniemi2014-06-021-8/+5
| | | | | | | (1) Enhance its description. (2) Simplify it: define only if has warn_unused_result. (3) Make it use STMT_START { ... } STMT_END to be less GNU-extensiony. (4) Redo 04783dc7 ("fix 'ignoring return value' compiler warnings") with it.
* Unify the "fall-through" lint annotation.Jarkko Hietaniemi2014-05-291-2/+2
| | | | | | | Used by linters (static checkers), and also good for human readers. Even though "FALL THROUGH" seems to be the most common, e.g BSD lint manual only knows "FALLTHROUGH" (or "FALLTHRU").
* fcntl receiving -1 from fileno, fcntl failing.Jarkko Hietaniemi2014-05-291-35/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Also very few spots of negative numgroups for getgroups(), and fgetc() return, but almost all checking is for fcntl.) (merged fix for perl #121743 and perl #121745: hopefully picked up all the fixes-to-fixes from the ticket...) Fix for Coverity perl5 CIDs 28990..29003,29005..29011,29013, 45354,45363,49926: Argument cannot be negative (NEGATIVE_RETURNS) fd is passed to a parameter that cannot be negative. and CIDs 29004, 29012: Argument cannot be negative (NEGATIVE_RETURNS) num_groups is passed to a parameter that cannot be negative and because of CIDs 29005 and 29006 also CID 28924. In the first set of issues a fd is retrieved from PerlIO_fileno, and that is then used in places like fstat(), fchown(), dup(), etc., without checking whether the fd is valid (>=0). In the second set of issues a potentially negative number is potentially passed to getgroups(). The CIDs 29005 and 29006 were a bit messy: fixing them needed also resolving CID 28924 where the return value of fstat() was ignored, and for completeness adding two croak calls (with perldiag updates): a bit of a waste since it's suidperl code.
* Hide the VMS error identifier SS$_NOPRIV, as customary.Jarkko Hietaniemi2014-05-281-1/+1
|
* [perl #121112] only warn if newline is the last non-NUL characterTony Cook2014-05-281-3/+3
|
* In Perl_nextargv(), move variable declarations into the blocks that use them.Nicholas Clark2014-03-191-8/+8
| | | | | This makes it clearer that variables don't hold values between iterations of the loop, and permits the variable sv to be made const.
* Simplify the code in Perl_nextargv().Nicholas Clark2014-03-191-21/+26
| | | | | | | | | Split the ternary that called Perl_do_open_raw() and Perl_do_open6() based on PL_inplace into two different if blocks, and merge these with the following code which is also conditional on PL_inplace. Remove the warning code from an else block and re-indent it, to make it clear that it is always called if control reaches the end of the while loop.
* Change core uses of Perl_do_openn() to Perl_do_open6() or Perl_do_open_raw().Nicholas Clark2014-03-191-9/+12
| | | | | | Calls to Perl_do_openn() all have at least 2 unused arguments which clutter the code and hinder easy understanding. Perl_do_open6() and Perl_do_open_raw() each only do one job, so don't have the dead arguments.
* Split Perl_do_openn() into Perl_do_open_raw() and Perl_do_open6().Nicholas Clark2014-03-191-11/+46
| | | | | | | Perl_do_open_raw() handles the as_raw part of Perl_do_openn(). Perl_do_open6() handles the !as_raw part of Perl_do_openn(). do_open6() isn't a great name, but I can't see an obvious concise name that covers 2 arg open, 3 arg open, piped open, implicit fork, and layers.
* Extract the cleanup code of Perl_do_openn() into S_openn_cleanup().Nicholas Clark2014-03-191-2/+26
| | | | | | A 12 parameter function is extremely ugly (as demonstrated by the need to add macros for it to perl.h), but it's private, and it will permit the two-headed public interface of Perl_do_openn() to be simplified.
* Extract the setup code of Perl_do_openn() into S_openn_setup().Nicholas Clark2014-03-191-19/+35
|
* In Perl_do_openn(), disambiguate the two separate uses of the variable fd.Nicholas Clark2014-03-191-8/+9
| | | | | Rename the first uses of the variable fd to wanted_fd to show that the variable is not used to pass a value to later in the function.
* In Perl_do_openn(), move the variable result into the block that uses it.Nicholas Clark2014-03-191-30/+35
| | | | | | This also removes a couple of places which would set result = 0 to simulate "success" for an a later if block. Those paths now don't even reach that if block.
* Perl_do_openn() doesn't need to set num_svs and svp.Nicholas Clark2014-03-191-19/+20
| | | | | | These variables are no longer used later in the function, so no need to set them. This permits the declaration of the variable namesv to be moved from the top of the function into the blocks that use it.
* Perl_do_openn() should call PerlIO_openn() with arg NULL if narg is 0.Nicholas Clark2014-03-191-1/+1
| | | | | | | | | | | | | If narg is NULL, then PerlIO_openn() doesn't look at args. (Technically except for PerlIOStdio_open() if f is non-NULL, which doesn't check narg and assumes that args[0] is valid. That lack of check is probably a bug. But it doesn't matter in this case, as f is NULL) This makes it clear that arg isn't needed at this point in Perl_do_openn(). This is a more complete version of the change made by commit dd37d22f759197ae (March 2002), which just changed the call to pass 0 for narg.
* In Perl_do_openn(), move {in,out}_{raw,crlf} into the !as_raw block.Nicholas Clark2014-03-191-11/+11
| | | | | | These 4 variables are only needed there, so by moving them into the block we save doing unneeded work for the as_raw case (ie sysopen), and as a side effect make the function a bit clearer.
* No need for code conditional on S_IFMT being defined, as perl.h has a fallback.Nicholas Clark2014-03-011-4/+0
| | | | | | | | | Commit c623bd54707a8bf9 (Jan 1991) added code conditionally compiled if S_IFMT was defined. However, the checks were immediately redundant, because the same commit also added code to perl.h to define a fallback value for S_IFMT if the OS headers did not define it, which is unchanged to this day. Hence the code added in an #else as part of commit 99b89507a1fb507c (Nov 1991) has never ever been needed.
* [perl #121230] fix kill -SIG on win32David Mitchell2014-02-281-5/+8
| | | | | | | | | | | | | | | | | | | | v5.17.1-137-gc2fd40c tidied up perl's kill() implementation, making -SIGNAME be handled correctly, It also eliminated the use of the killpg() system/library call, which these days is usually just a thin wrapper over kill(). By doing this, it assumed that the following are functionally equivalent: killpg(pgrp, sig) kill(-pgrp, sig). Unfortunately this broke Window's use of the (perl-level) kill negative_value, pid, ... since under Windows, the killpg()/kill() identity doesn't hold (win32_kill() uses negative ids for fake-PIds, not process groups). Fix this by restoring the use of killpg() where available.
* Change av_len calls to av_tindex for clarityKarl Williamson2014-02-201-1/+1
| | | | | | av_tindex is a more clearly named synonym for av_len, available starting in v5.18. This changes the core uses to it, including modules in /ext, which are not dual-lifed.
* Consistent spaces after dots in perlintern.podFather Chrysostomos2013-12-291-1/+1
|
* Purge sfio support, which has been broken for a decade.Nicholas Clark2013-12-271-7/+0
| | | | | | | | | | | The last Perl release that built with -Dusesfio was v5.8.0, and even that failed many regression tests. Every subsequent release fails to build, and in the decade that has passed we have had no bug reports about this. So it's safe to delete all the code. The Configure related code will be purged in a subsequent commit. 2 references to sfio intentionally remain in fakesdio.h and nostdio.h, as these appear to be for using its stdio API-compatibility layer.
* doio.c: Stop semop from modifying its argumentFather Chrysostomos2013-12-251-9/+0
| | | | | | | | | | | | | | | | | | | Perl_do_semop, which implements the Perl semop function, copies its second argument to a new struct array, which it passes to the system’s semop function. It then copies the contents of the struct back into the argument’s string buffer. Neither the Darwin nor Linux documentation says that semop modifies the structs passed to it, and, even if it did happen, perl has never handle it correctly. It would have to stringify its argument forcibly (to avoid copying back into a temporary string buffer) and also call get-magic. And then it would fail with a read-only argument. Since read-only arguments have always been permitted and the copy ing-back has never worked correctly, and since this will cause prob- lems if we upgrade modifications to COW buffers into crashes (the PERL_DEBUG_READONLY_COW mode I am working in), this commit removes that code.
* Fixes the case where on 64bit big-endian boxes, calls to ↵Brian Childs2013-12-091-2/+7
| | | | semctl(id,semnum,SETVAL,$wantedval) will ignore the passed in $wantedval, and always use 0
* doio.c: Remove EBCDIC dependencyKarl Williamson2013-12-031-4/+0
| | | | | For non-EBCDIC this file used \012 instead of \n. This may have been a MAC OS Classic hack, which we no longer support.
* Check unlink on directory for all users, not just root.Craig A. Berry2013-12-021-1/+1
| | | | | | | | | For cross-platform consistency, it makes more sense to reject unlink attempts on directories in the same way for all users rather than only for root. geteuid() always returns zero on Windows, never returns zero on VMS, and is a poor indicator of privilege on modern unixen, so the code really hasn't been working as intended on all platforms anyway.
* Make unlink on directory as root set errno.Evan Zacks2013-12-021-1/+5
| | | | | | | | | | | | | | | If unlink is called on an existing directory while running as root without -U (PL_unsafe), the unlink call fails but does not set $!, because unlink(2) is not actually called in this case. If unlink is called as a user (or as root with -U), unlink(2) is invoked, so attempting to remove a directory would set errno to EISDIR as expected. If running as root without -U (PL_unsafe is false), lstat and S_ISDIR are called instead. If the lstat succeeds and S_ISDIR returns true, the argument is skipped without warning and without setting $!, meaning Perl's unlink can return failure while leaving the previous value of errno in place. This commit sets errno to EISDIR for this case.
* silence -Wformat-nonliteral compiler warningsDavid Mitchell2013-11-281-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the security risks associated with user-supplied formats being passed to C-level printf() style functions (eg %n), gcc has a -Wformat-nonliteral warning that complains whenever such a function is passed a non-literal format string. This commit silences all such warnings in core and ext/. The main changes are 1) the 'f' (format) flag in embed.fnc is now handled slightly more cleverly. Rather than just applying to functions whose last arg is '...' (and where the format arg is assumed to be the previous arg), it can now handle non-'...' functions: arg checking is disabled, but format checking is sill done: it works by assuming that an arg called 'fmt', 'pat' or 'f' is the format string (and dies if fails to find exactly one such arg). 2) with the new embed.fnc functionally, more functions have been marked with the 'f' flag. When such a function passes its fmt arg onto an inner printf-like function, we simply disable the warning for that call using GCC_DIAG_IGNORE(-Wformat-nonliteral), since we know that the caller must have already checked it. 3) In quite a few places the format string isn't literal, but it *is* constant (e.g. PL_warn_uninit_sv). For those cases, again disable the warning. 4) In pp_formline(), a particular format was was one of several different literal strings depending on circumstances. Rather than assigning this string to a temporary variable, incorporate the ?: branches directly in the function call arg. gcc is clever enough to decide the arg is then always literal.
* fix 'ignoring return value' compiler warningsDavid Mitchell2013-11-241-3/+8
| | | | | | | | | | | Various system functions like write() are marked with the __warn_unused_result__ attribute, which causes an 'ignoring return value' warning to be emitted, even if the function call result is cast to (void). The generic solution seems to be int rc = write(...); PERL_UNUSED_VAR(rc);
* silence some compiler warningsDavid Mitchell2013-11-131-1/+1
| | | | | | | Actually, most of this commit is adding (void) to various function returns where we know its ok to ignore the return value. This doesn't actually silence the -Wunused-result warning (thanks a bundle gcc), but at least it marks our intentions.
* Removed the ifdefs for INCOMPLETE_TAINTSBrian Fraser2013-09-211-4/+0
| | | | | This was added in 5.5/5.6 as a backwards-compatibility measure when taint was extended to happen in more places.
* Remove the ifdefs for ULTRIX_STDIO_BOTCHBrian Fraser2013-09-211-8/+0
| | | | | Not only has Ultrix been long out of support, this ifdef was working around a bug particular to Ultrix 1.2.
* [perl #117265] move the "glob failed" warning to the point of failureTony Cook2013-09-091-0/+6
| | | | This avoids an extraneous warning when globbing fails for other reasons.
* [perl #117265] correctly handle overloaded stringsTony Cook2013-09-091-12/+18
|
* [perl #117265] safesyscalls: check embedded nul in syscall argsTony Cook2013-08-261-4/+21
| | | | | | | | | | | | | | | | Check for the nul char in pathnames and string arguments to syscalls, return undef and set errno to ENOENT. Added to the io warnings category syscalls. Strings with embedded \0 chars were prev. ignored in the syscall but kept in perl. The hidden payloads in these invalid string args may cause unnoticed security problems, as they are hard to detect, ignored by the syscalls but kept around in perl PVs. Allow an ending \0 though, as several modules add a \0 to such strings without adjusting the length. This is based on a change originally by Reini Urban, but pretty much all of the code has been replaced.
* -l $handle warning: globs, iorefs, utf8Father Chrysostomos2013-06-041-3/+18
| | | | | | | | The warning restored in commit cd22fad3cbcea only applied to globrefs, not to globs or iorefs. The warning message was also not utf8-clean. This commit fixes both. This resolves ticket #117595.
* Fix -Wformat-security issuesNiko Tyni2013-05-101-2/+2
| | | | | | | | Building with -Accflags="-Wformat -Werror=format-security" triggers format string warnings from gcc. As gcc can't tell that all the strings are constant here, explicitly pass separate format strings to make it happy.
* silence warnings under NO_TAINT_SUPPORTDavid Mitchell2013-05-091-0/+2
| | | | | The are lots of places where local vars aren't used when compiled with NO_TAINT_SUPPORT.
* Restore the warning previously issued by (-l $fh)Ricardo Signes2013-05-081-2/+7
| | | | | | | | | | This is a partial reversion of 433644eed8, which removed a secondary, short-circuiting behavior when the warning was issued. Now, the warning is issued, but the normal behavior (treat the handle as a string) is maintained. This work was done after subsequent refactoring to doio.c, so it couldn't be just a reversion with the "return" statement removed.
* Add return statements where missing in doio.c IPC functions.Craig A. Berry2013-03-031-0/+3
| | | | | | | | These are code paths not seen on platforms that have msg* and shm* functions, and of course we're croaking before returning so returning is pointless, but the VMS C compiler insists that we have return statments for non-void functions anyway, and that compiler now sees these functions since enabling sem*.
* Change core calls of isALNUM() to isWORDCHAR()Karl Williamson2012-12-311-1/+1
| | | | The latter is more clearly named to indicate it includes the underscore.
* doio.c: Use SvREFCNT_dec_NNFather Chrysostomos2012-12-091-1/+1
| | | | | | The sole use of SvREFCNT_dec in doio.c is on a variable than is never null (setdefout would fail an assertion otherwise), so no need to check whether it is.
* Silence some g++ compiler warningsKarl Williamson2012-12-091-1/+1
| | | | | Changing these slightly got rid of the warnings like: toke.c:9168: warning: format not a string literal and no format arguments
* Remove "register" declarationsKarl Williamson2012-11-241-6/+6
| | | | | | | This finishes the removal of register declarations started by eb578fdb5569b91c28466a4d1939e381ff6ceaf4. It neglected the ones in function parameter declarations, and didn't include things in dist, ext, and lib, which this does include
* Remove the EPOC port.Nicholas Clark2012-11-191-1/+1
| | | | | | | EPOC was a family of operating systems developed by Psion for mobile devices. It was the predecessor of Symbian. The port was last updated in April 2002.