This is a live mirror of the Perl 5 development currently hosted at
https://github.com/perl/perl5
https://perl5.git.perl.org
/
perl5.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b66176f
)
lseek fd can be bad.
author
Jarkko Hietaniemi
<jhi@iki.fi>
Tue, 23 Jun 2015 10:51:37 +0000
(06:51 -0400)
committer
Jarkko Hietaniemi
<jhi@iki.fi>
Sat, 27 Jun 2015 03:09:41 +0000
(23:09 -0400)
Coverity CID 104788
ext/POSIX/POSIX.xs
patch
|
blob
|
blame
|
history
diff --git
a/ext/POSIX/POSIX.xs
b/ext/POSIX/POSIX.xs
index
670d8ec
..
514b514
100644
(file)
--- a/
ext/POSIX/POSIX.xs
+++ b/
ext/POSIX/POSIX.xs
@@
-3210,9
+3210,14
@@
lseek(fd, offset, whence)
Off_t offset
int whence
CODE:
Off_t offset
int whence
CODE:
- Off_t pos = PerlLIO_lseek(fd, offset, whence);
- RETVAL = sizeof(Off_t) > sizeof(IV)
- ? newSVnv((NV)pos) : newSViv((IV)pos);
+ if (fd >= 0) {
+ Off_t pos = PerlLIO_lseek(fd, offset, whence);
+ RETVAL = sizeof(Off_t) > sizeof(IV)
+ ? newSVnv((NV)pos) : newSViv((IV)pos);
+ } else {
+ SETERRNO(EBADF,RMS_IFI);
+ RETVAL = newSViv(-1);
+ }
OUTPUT:
RETVAL
OUTPUT:
RETVAL