Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Integer overflow in -s or file stat results

by BrowserUk (Patriarch)
on Mar 07, 2017 at 17:00 UTC ( [id://1183850]=note: print w/replies, xml ) Need Help??


in reply to Integer overflow in -s or file stat results

It'll probably suffer the same flaw, but you could try POSIX::lseek with SEEK_END and an offset of 0. If successful it returns the byte offset of the position it reached.

If it was really important to avoid system, you could step through the file using seek() with SEEK_CUR and a relative offset of 2**31 (remembering how many steps) and reading a byte until the read fails; then step back to the last good position and do a binary chop until you find the last position at which you can read a byte.

All in all, system is almost certainly preferable.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Integer overflow in -s or file stat results
by Laurent_R (Canon) on Mar 07, 2017 at 18:30 UTC
    Thank you, BrowserUk for your help.

    POSIX's lseek does indeed suffer of the same flaw and returns a negative integer.

    I guess you're right: unless some other monk comes up with a miraculous solution, I'll stick with with a call to the VMS system.

    Thank you for your help.

    Update: fixed a typo.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1183850]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-29 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found