Syndicate content

Bad move for PHP unpack()! So unpack() stopped working?

Today I noticed many errors on one of my websites. Looking closer into it, I noticed that the code for the mo_references Drupal module stopped working.

It took me some time, especially because the code seemed to work just fine as all the files could easily be displayed.

Actually, that was not the case. The unpack() character 'a', which I used, was transformed from a simple string that gets trimmed, to all the characters, including the NULL characters. Ouch! Now we have to use the 'Z' character instead.

I use it to unpack() a tar file by loading 512 bytes of data in a variable and then extracting the different fields with the unpack() command as in:

[...]
$block = gzread($gz, 512)
$header = unpack("Z100name/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/"
               . "Z8checksum/Z1type/Z100symlink/Z6magic/Z2temp/"
               . "Z32temp/Z32temp/Z8temp/Z8temp/Z155prefix/Z12temp", $block);
if($header['magic'] == 'ustar')
{
   // looks valid, go on
}

Source: http://www.php.net/manual/en/function.unpack.php

Syndicate content

Diverse Realty

Diverse Realty Team

Want a New Home?
Want to Sell Your House?

Call Alex at
+1 (916)
220 6482

Alexis Wilke, Realtor
Salesperson
Lic. # 02024063

Cory Marcus, Broker
Lic. # 01079165

     

Terms of Site Index

Find the page/content you are looking for with our index.