Skip to main content
Topic: Errors when installing and removing a package (Read 5450 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Errors when installing and removing a package

Reply #15

Just backing up in the code to line 180, trying to see why you get an extra '/'
Code: [Select]
if ($current['type'] == 5 && substr($current['filename'], -1) != '/')
 $current['filename'] .= '/';

That could add in an extra '/' but it should not do it if thats already there, could you print out the $current['filename'] at that point as well ... type 5 is a directory type as defined by the tar header.

ETA: for me its string(12) "language.xml" string(11) "license.txt" string(16) "package-info.xml" string(9) "readme.md" string(10) "readme.txt" string(12) "redirect.txt" string(19) "remove_settings.php" string(8) "sources/" string(30) "sources/hideusernames.subs.php" string(13) "uninstall.txt" string(12) "language.xml" string(11) "license.txt" string(16) "package-info.xml"

Re: Errors when installing and removing a package

Reply #16

Sorry but I probably won't be able to get more debug until tomorrow.  Maybe very late tonight.

Re: Errors when installing and removing a package

Reply #17

Ok, I think I found the problem problem, but I'm not enough of a php coder to be sure of the fix.  At line 180, after all the files actually in the tgz file have printed correctly (including the directory with a / already there) there is one more entry.

Code: [Select]
$current = Array
(
    [filename] =>
    [mode] =>
    [uid] =>
    [gid] =>
    [size] =>
    [mtime] =>
    [checksum] =>
    [type] =>
    [linkname] =>
    [magic] =>
    [version] =>
    [uname] =>
    [gname] =>
    [devmajor] =>
    [devminor] =>
    [path] =>
)

This doesn't seem unexpected given this a little above line 180

Code: [Select]
    // Blank record?  This is probably at the end of the file.
    if (empty($current['filename']))
    {
      $offset += 512;
      continue;
    }

But empty($current['filename']) is returning false for that record.  Probably because the unpack above is unpacking it as a100 which fits with strlen($current['filename']) returning 100 when I print it.  100 spaces or other unprintable characters I guess?   So probably a test other than empty needs to be used for the blank record.

I'm not sure why this is the case for me but not you though.

Re: Errors when installing and removing a package

Reply #18

Thanks !

Looking at the code, one thing I want to try is to move the sanitizing step first and then the checks after.  So right now its
Code: (current) [Select]
	if (empty($current['filename']))
{
$offset += 512;
continue;
}

if ($current['type'] == 5 && substr($current['filename'], -1) != '/')
$current['filename'] .= '/';

foreach ($current as $k => $v)
{
if (in_array($k, $octdec))
$current[$k] = octdec(trim($v));
else
$current[$k] = trim($v);
}
lets reorder that to
Code: (repalce with) [Select]
		foreach ($current as $k => $v)
{
if (in_array($k, $octdec))
$current[$k] = octdec(trim($v));
else
$current[$k] = trim($v);
}

// Blank record?  This is probably at the end of the file.
if (empty($current['filename']))
{
$offset += 512;
continue;
}

if ($current['type'] == 5 && substr($current['filename'], -1) != '/')
$current['filename'] .= '/';

This places the trim of the array values and the octdec conversion first .. then the next to checks should have clean data.  If it still fails at that point we will need to see if there are other than blanks in those fields.

Re: Errors when installing and removing a package

Reply #19

That worked on my package and yours.  No more blank entries in the list at 180ish and no more errors in the log.

Re: Errors when installing and removing a package

Reply #20

Awesome ! .. I'll add it to a PR and get it merged in.

Thank you for you help in debugging this :D