Bug 13631

Summary: /usr/lib/rpm/rpm2cpio.sh fails in zh_TW locale (and probably others)
Product: Mageia Reporter: Joseph Wang <joequant>
Component: RPM PackagesAssignee: Thierry Vignaud <thierry.vignaud>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: pterjan, thierry.vignaud
Version: Cauldron   
Target Milestone: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: MGA5TOO
Source RPM: rpm-4.11.2-6.mga5.src.rpm CVE:
Status comment:
Attachments: fix rpm2cpio.sh

Description Joseph Wang 2014-07-01 16:57:41 CEST
Description of problem:

/usr/lib/rpm/rpm2cpio.sh fails on zh_TW locale (and probably other non-Latin locales)




Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. install and log in as zh_TW.  

It has the following environment

LC_PAPER=zh_TW.UTF-8
LC_ADDRESS=zh_TW.UTF-8
LC_MONETARY=zh_TW.UTF-8
LC_NUMERIC=zh_TW.UTF-8
LC_TELEPHONE=zh_TW.UTF-8
LC_MESSAGES=zh_TW.UTF-8
LC_COLLATE=zh_TW.UTF-8
LC_IDENTIFICATION=zh_TW.UTF-8
LANG=zh_TW.UTF-8
LC_MEASUREMENT=zh_TW.UTF-8
LANGUAGE=zh_TW.Big5:zh_TW:zh_HK:zh
LC_CTYPE=zh_TW.UTF-8
LC_TIME=zh_TW.UTF-8
LC_NAME=zh_TW.UTF-8

Run rpm2cpio.sh against an rpm and you get

[joe@big-apple ~]$ /usr/lib/rpm/rpm2cpio.sh  lib64lua5.2-5.2.3-3.mga5.x86_64.rpm 
Unrecognized rpm file: lib64lua5.2-5.2.3-3.mga5.x86_64.rpm

Setting "export LC_ALL=C" makes this work.

The issue appears to be that setting LC_ALL causes printf to behave differently on non-Roman locales



Reproducible: 

Steps to Reproduce:
Comment 1 Pascal Terjan 2014-07-01 17:20:08 CEST
I can try later but can you run those commands?

echo . | awk '{ printf("%c%c", 0x1f, 0x8b); }' | od -x
echo . | awk '{ printf("%cLZ", 0xff); }' | od -x
echo . | awk '{ printf("%c7z", 0xfd); }' | od -x

I would tend to blame Big5 :)

CC: (none) => pterjan

Comment 2 Pascal Terjan 2014-07-01 17:27:42 CEST
So I was wrong:

$ echo . | awk '{ printf("%c%c", 0x1f, 0x8b); }' | od -x
0000000 8b1f
0000002


$ echo . | LANG=zh_TW.UTF-8 awk '{ printf("%c%c", 0x1f, 0x8b); }' | od -x
0000000 c21f 008b
0000003
Thierry Vignaud 2014-07-01 17:32:03 CEST

CC: (none) => thierry.vignaud
Assignee: bugsquad => thierry.vignaud

Samuel Verschelde 2015-05-31 23:29:01 CEST

Whiteboard: (none) => MGA5TOO

Comment 3 Thierry Vignaud 2016-10-19 15:10:38 CEST
Actually there was a fix for it upstream in 2012:
https://bugzilla.redhat.com/show_bug.cgi?id=878363

But it's still broken on mga (though it works on FC24, but with different versions of glibc & gawk).
Its' broken for ar, br, el, fr, pl, zh_TW now...
Comment 4 Thierry Vignaud 2016-10-19 15:11:48 CEST
Created attachment 8577 [details]
fix rpm2cpio.sh

This patch fixes it for me
Alternatively, using the upstream refactoring works as fine:
http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=19dbaff8dd051688c0acf1b6605bf13a7fe019bd
Comment 5 Thierry Vignaud 2016-10-19 15:16:51 CEST
Fixed in SVN

Status: NEW => RESOLVED
Resolution: (none) => FIXED