RPM

app-arch/rpm2targz: unable to unpack lzma compressed rpms

Bug #634154 reported by Jeff Johnson
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
RPM
Triaged
Low
Unassigned
Gentoo Linux
Unknown
Medium

Bug Description

tracker

Tags: gentoo lzma
Revision history for this message
In , pva (pva) wrote :

Hi. Altlinux uses rpm files which are packed with lzma. For example download[1] src.rpm and try to rpm2targz it - that fail. I've found inside lzma-4.32.7.tar.bz2 code to check if that's lzma archive:

int find_lzma_header(unsigned char *buf) {
    return (buf[0] < 0xE1
        && buf[0] == 0x5d
        && buf[4] < 0x20
        && (memcmp (buf + 10 , "\x00\x00\x00", 3) == 0
            || (memcmp (buf + 5, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 8) == 0)));
}

and patched rpmoffset.c to check for lzma too (patch follows). Now it works, but it makes code not such nice as it was before... Patch follows.

[1] http://sisyphus.ru/ru/srpm/Sisyphus/man-pages-ru/get
[2] lzma-4.32.7/extra/scanlzma/scanlzma.c

Revision history for this message
In , pva (pva) wrote :

Created attachment 232875
rpmoffset.c.patch

The question is should we go this way or what? In any case there is real need to support lzma packed rpms...

Revision history for this message
In , Mike Frysinger (vapier) wrote :

that wont work on all lzma archives either as some implementations fill out the filesize field (that 8 byte field).

simply extend the existing magic logic and look for the first few lzma bytes. also post a link to an archive that isnt working for you.

Revision history for this message
In , pva (pva) wrote :

This is link on archive that does not work:

ftp://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/files/SRPMS/man-pages-ru-0.98-alt19.src.rpm

This link could became invalid also the one in comment #0 should work.

And I'm not sure how to extend magic logic... :( As I understand this code if people fill filesize field then they should have memcmp (buf + 10 , "\x00\x00\x00", 3) == 0 so afais this is handled with this check.

Revision history for this message
In , Onur Küçük (onur-pardus) wrote :

With this patch applied, some (maybe all ?) rpm files created with xz fails to unpack. The problem is, they contain lzma signature and it is present towards the beginning of the file. I have made some modifications, so that rpmoffset continues to search when lzma is detected, in case there is xz data later in the file. See [1] for example. There are a few more rpms in that folder to test with too.

http://cekirdek.pardus.org.tr/~onur/rpm2targz/system-config-nfs-1.3.49-1.fc12.noarch.rpm

Revision history for this message
In , Onur Küçük (onur-pardus) wrote :

Created attachment 241561
lzma patch with xz fix

Revision history for this message
In , Mike Frysinger (vapier) wrote :

Created attachment 244145
rpm2targz-lzma.patch

it isnt that there is a lzma signature so much that the lzma check is way too permissive. the current code:

+ buf[0] < 0xE1 && buf[0] == 0x5d
this is dumb because you cant have a value of 0x5d without being less than 0xe1

the gist of it is that if you have a bit stream that matches:
  0x5d 0x.. 0x.. 0x.. (0x.. < 0x20) 0x.. 0x.. 0x.. 0x.. 0x.. 0x00 0x00 0x00

that's a bit too fuzzy for my tastes.

at any rate, the current patches have style issues up the wazoo, so try this patch instead.

Revision history for this message
In , Onur Küçük (onur-pardus) wrote :

(In reply to comment #6)
...
> that's a bit too fuzzy for my tastes.

 Agreed, but IIRC that is how it is with (old) lzma

> at any rate, the current patches have style issues up the wazoo, so try this
> patch instead.

 This patch looks fine to me, I have tested with some samples, no problem so far.

Revision history for this message
In , Jeff Johnson (n3npq) wrote :
tags: added: gentoo lzma
Revision history for this message
In , Mike Frysinger (vapier) wrote :

why ? i see no point in that.

Jeff Johnson (n3npq)
Changed in rpm:
status: New → Triaged
importance: Undecided → Low
Changed in gentoo:
status: Unknown → Confirmed
Changed in gentoo:
importance: Unknown → Medium
Revision history for this message
In , pva (pva) wrote :

(In reply to comment #6)
> Created attachment 244145 [details]
> rpm2targz-lzma.patch
>
> at any rate, the current patches have style issues up the wazoo, so try this
> patch instead.

It works for me too. Can we have it in the tree?

Changed in gentoo:
status: Confirmed → Unknown
Revision history for this message
In , Pacho-gentoo (pacho-gentoo) wrote :

*** Bug 377173 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Pacho-gentoo (pacho-gentoo) wrote :

I also suffer from this problem as openSUSE is also providing this kind of rpm files :-S

Could that patch be applied if possible? Thanks a lot

Revision history for this message
In , chris stankevitz (chrisstankevitz-q) wrote :

Hi,

Can someone tell me how to apply this patch to my system? I need to unpack a lzma rpm. I'm willing to make portage overlay, jump through hoops, stand on head, etc, I just need to know what to do.

Thank you

Revision history for this message
In , chris stankevitz (chrisstankevitz-q) wrote :

This shows the basic idea to get a patch:

http://en.gentoo-wiki.com/wiki/Writing_Ebuilds#Adding_a_patch

1. Create a portage overlay for rpm2targz
2. Add the patch to the files directory
3. Modify the ebuild as per the above link
4. ebuild xxx digest
5. emerge -vat rpm2targz

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.