if ($chunk == 0xffffffffffffffffffffffff)

A

A. Farber

Hi,

I'm trying to verify that a file (uploaded via HTTP)
has 24 bytes with the value 0xff at some offset:

die "sysseek to $place failed: $!"
unless sysseek $fh, $place, SEEK_SET;
die "sysread failed: $!"
unless 24 == sysread $fh, $check, 24;
unless (0xffffffffffffffffffffffff == $check) {
printf "Checksum storage area at 0x%X is not empty", $place;
exit;
}

However the condition above is never true on
RedHat 9 with Perl 5.6.1. Any suggestions please?

Regards
Alex
 
W

Walter Roberson

:I'm trying to verify that a file (uploaded via HTTP)
:has 24 bytes with the value 0xff at some offset:

: unless 24 == sysread $fh, $check, 24;
: unless (0xffffffffffffffffffffffff == $check) {

:However the condition above is never true on
:RedHat 9 with Perl 5.6.1. Any suggestions please?

0xffffffffffffffffffffffff is a number that is overflowing
the maximum integer available.

Try unless (("\xff" x 24) == $check)
 
B

Ben Morrow

:I'm trying to verify that a file (uploaded via HTTP)
:has 24 bytes with the value 0xff at some offset:

: unless 24 == sysread $fh, $check, 24;
: unless (0xffffffffffffffffffffffff == $check) {

:However the condition above is never true on
:RedHat 9 with Perl 5.6.1. Any suggestions please?

0xffffffffffffffffffffffff is a number that is overflowing
the maximum integer available.

Try unless (("\xff" x 24) == $check)
^^
eq
Ben
 
A

Anno Siegel

A. Farber said:
Hi,

I'm trying to verify that a file (uploaded via HTTP)
has 24 bytes with the value 0xff at some offset:

"24 bytes with value 0xff" can mean a few different things. Do you mean,
each of the 24 bytes has value 0xff (255)?
die "sysseek to $place failed: $!"
unless sysseek $fh, $place, SEEK_SET;
die "sysread failed: $!"
unless 24 == sysread $fh, $check, 24;

Why are you using sysseek(), sysread(), etc? What is your reason for not
using standard IO functions?
unless (0xffffffffffffffffffffffff == $check) {

That is a 12 byte number. Perl doesn't deal natively with numbers that
wide (nor does anything else). But it still is only half the length of
your 24 bytes.

But your code wouldn't work even if you only had 4 bytes (which fit into
a native integer on most machines). Perl reads strings from files, not
numbers. So, if you read 24 bytes of one-bits, a string of 24 bytes of
one-bits is what you get. Try string comparison with that value:

$check eq "\xff" x 24;

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top