Connecting Tech Pros Worldwide Forums | Help | Site Map

Hexadecimal number > 0xffffffff non-portable

Newbie
 
Join Date: Jul 2009
Posts: 6
#1: Jul 30 '09
Could someone please help me to resolve the following error.

Integer overflow in hexadecimal number at Keystore.pm line 1106.
Hexadecimal number > 0xffffffff non-portable Keystore.pm line 1106.

Thanks in advance

Member
 
Join Date: Jun 2009
Posts: 54
#2: Jul 30 '09

re: Hexadecimal number > 0xffffffff non-portable


Can you post the complete line of code at line 1106?

What OS are you on?

What version of Perl are you using?

Do you get the same error from this test script?

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4.  
  5. print 0xffffffff, "\n";  # comment this line out if you receive the error
  6.  
  7. print 2**32, "\n";  # does this produce the same error?
  8.  
Newbie
 
Join Date: Jul 2009
Posts: 6
#3: Jul 30 '09

re: Hexadecimal number > 0xffffffff non-portable


$ cat test.pl
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4.  
  5. print 0xffffffff, "\n";  # comment this line out if you receive the error
  6.  
  7. print 2**32, "\n";  # does this produce the same error?
  8.  
$

$ perl test.pl
4294967295
4294967296
$



$ perl -v

This is perl, v5.8.4 built for sun4-solaris-64int
(with 31 registered patches, see perl -V for more detail)
Newbie
 
Join Date: Jul 2009
Posts: 6
#4: Jul 30 '09

re: Hexadecimal number > 0xffffffff non-portable


this is from the keystore.pm
Expand|Select|Wrap|Line Numbers
  1.     ####
  2.     # serial number
  3.     # extract hex certificate serial number (only required for -text format)
  4.     #$certinfo->{SerialNumber} =~ s/.*\(0x(.*)\)/$1/;
  5.  
  6.     # store decimal serial number
  7.     $certinfo->{Serial} = hex($certinfo->{SerialNumber});
  8.  
  9.     # pad with a leading zero if length is odd
  10.     if (length($certinfo->{SerialNumber}) % 2)
  11.     {
  12.         $certinfo->{SerialNumber} = '0' . $certinfo->{SerialNumber};
  13.     }
  14.     # convert to upcase and insert colons to separate hex bytes
  15.     $certinfo->{SerialNumber} = uc($certinfo->{SerialNumber});
  16.     $certinfo->{SerialNumber} =~ s/(..)/$1:/g;
  17.     $certinfo->{SerialNumber} =~ s/:$//;
  18.  
  19.     ####
  20.  
Member
 
Join Date: Jun 2009
Posts: 54
#5: Jul 30 '09

re: Hexadecimal number > 0xffffffff non-portable


Prior to the hex( ) command, what is the actual value of:
$certinfo->{SerialNumber}

If you uncomment this line, I'm willing to bet that the error goes away.
#$certinfo->{SerialNumber} =~ s/.*\(0x(.*)\)/$1/;

However, that may not give you the final results that you expect.
Member
 
Join Date: Jun 2009
Posts: 54
#6: Jul 30 '09

re: Hexadecimal number > 0xffffffff non-portable


I think I found the issue. Your OS is 64 bit, but it appears that Perl was built for 32 bit.

You should be able to get around this, without recompiling Perl, by using Math::BigInt
Expand|Select|Wrap|Line Numbers
  1. use Math::BigInt;
  2.  
  3. $certinfo->{Serial} = Math::BigInt->new($certinfo->{SerialNumber})->as_hex;
  4.  
Resource:
http://www.perlmonks.org/?node_id=616866
Newbie
 
Join Date: Jul 2009
Posts: 6
#7: Jul 30 '09

re: Hexadecimal number > 0xffffffff non-portable


Am sorry, still getting the same error.

Also, had attached the Keystore module.

Please rename Keystore.txt to Keystore.pm.

Thanks
Attached Files
File Type: txt Keystore.txt (47.8 KB, 16 views)
Member
 
Join Date: Jun 2009
Posts: 54
#8: Jul 30 '09

re: Hexadecimal number > 0xffffffff non-portable


We were posting about the same time, so you may have missed my last comment.

Try using Math::BigInt
Member
 
Join Date: Jun 2009
Posts: 54
#9: Jul 30 '09

re: Hexadecimal number > 0xffffffff non-portable


Another resource for the solution.
http://www.perlmonks.org/?node_id=742688
Newbie
 
Join Date: Jul 2009
Posts: 6
#10: Jul 30 '09

re: Hexadecimal number > 0xffffffff non-portable


Hey many thanks,

Am not getting this error any more.

Thanks again.
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,571
#11: Jul 30 '09

re: Hexadecimal number > 0xffffffff non-portable


bprabhu17, you need to please start using code tags when you are posting code in the forums. They are required around any code you post, that way we don't have to clean up behind you.

Regards,

Jeff
Reply