megastep / makeself

A self-extracting archiving tool for Unix systems, in 100% shell script.
https://makeself.io
GNU General Public License v2.0
2.32k stars 372 forks source link

Division by zero on small files (UID too large?) #324

Open bjackman opened 8 months ago

bjackman commented 8 months ago

Using Makeself version 2.5.0:

/tmp/ms  
❯❯  echo "echo foo" > run.sh

/tmp/ms  
❯❯  chmod +x run.sh 

/tmp/ms  
❯❯  ./run.sh 
foo

/tmp/ms  
❯❯  makeself . run.run "run" "./run.sh"
Header is 714 lines long

About to compress 8 KB of data...
Adding files to archive named "run.run"...
a ./run.shbsdtar: ./run.sh: Numeric user ID too large

CRC: 1837495207
MD5: 7c560c71742f4fa9533dfb1088632ea1

Self-extractable archive "run.run" successfully created.

/tmp/ms  
❯❯  ./run.run 
Verifying archive integrity...     0% expr: division by zero
./run.run: line 137: test: -lt: unary operator expected
 100%   MD5 checksums are OK. All good.
Uncompressing run     0% expr: division by zero
./run.run: line 137: test: -lt: unary operator expected
 100%  
./run.run: line 701: ./run.sh: No such file or directory

I'm not sure if that "Numeric user ID too large" warning is related, it might always have been there - I don't have logs from an older version of makeself to compare unfortunately. My UID is 729974 for what that's worth - I assume this is much bigger than you'd usually encounter on a plain old local Unix system but this is on a fancy work system with PAM magic.

bjackman commented 8 months ago

I bisected the "Numeric user ID too large" thing to 64674c741600cf0e1879cd098e4038cf5ca5d8fe. Kinda seems like it's unrelated to the division by zero.

bjackman commented 8 months ago

Hmm OK I tried ignoring the UID thing:

❯❯  git checkout  64674c7
Previous HEAD position was 5742be6 Updated link to release
HEAD is now at 64674c7 add test on Alpine and Nanoserver using busybox (#265)

~/src/makeself ((64674c74))                                                                                                                                                                                                                                                               
❯❯  make -j clean && make -j                                                                                                                                                                                                                                                              
rm -f makeself-*.run                                                                                                                                                                                                                                                                      
./make-release.sh                                                                                                                                                                                                                                                                         
Header is 716 lines long                                                                                                                                                                                                                                                                  

WARNING: Overwriting existing file: release/makeself-2.4.5.run                                                                                                                                                                                                                            
About to compress 204 KB of data...                                                                                                                                                                                                                                                       
Adding files to archive named "release/makeself-2.4.5.run"...                                                                                                                                                                                                                             
a ./.gitmodulesbsdtar: ./.gitmodules: Numeric user ID too large

a ./COPYINGbsdtar: ./COPYING: Numeric user ID too large

a ./README.mdbsdtar: ./README.md: Numeric user ID too large

a ./VERSIONbsdtar: ./VERSION: Numeric user ID too large

a ./makeself-header.shbsdtar: ./makeself-header.sh: Numeric user ID too large

a ./makeself.1bsdtar: ./makeself.1: Numeric user ID too large

a ./makeself.lsmbsdtar: ./makeself.lsm: Numeric user ID too large

a ./makeself.shbsdtar: ./makeself.sh: Numeric user ID too large

a ./test/appendtestbsdtar: ./test/appendtest: Numeric user ID too large

a ./test/bashunit/.gitbsdtar: ./test/bashunit/.git: Numeric user ID too large

a ./test/bashunit/LICENSEbsdtar: ./test/bashunit/LICENSE: Numeric user ID too large

a ./test/bashunit/README.mdbsdtar: ./test/bashunit/README.md: Numeric user ID too large

a ./test/bashunit/bashunit.bashbsdtar: ./test/bashunit/bashunit.bash: Numeric user ID too large

a ./test/bashunit/test_examplebsdtar: ./test/bashunit/test_example: Numeric user ID too large

a ./test/corrupttestbsdtar: ./test/corrupttest: Numeric user ID too large

a ./test/datetestbsdtar: ./test/datetest: Numeric user ID too large

a ./test/extracttestbsdtar: ./test/extracttest: Numeric user ID too large

a ./test/infotestbsdtar: ./test/infotest: Numeric user ID too large

a ./test/lsmtestbsdtar: ./test/lsmtest: Numeric user ID too large

a ./test/secret_key.gpgbsdtar: ./test/secret_key.gpg: Numeric user ID too large

a ./test/signtestbsdtar: ./test/signtest: Numeric user ID too large

a ./test/suidtestbsdtar: ./test/suidtest: Numeric user ID too large

a ./test/tarextratestbsdtar: ./test/tarextratest: Numeric user ID too large

a ./test/variabletestbsdtar: ./test/variabletest: Numeric user ID too large

a ./test/whitespacelicensetestbsdtar: ./test/whitespacelicensetest: Numeric user ID too large

a ./test/whitespacetestbsdtar: ./test/whitespacetest: Numeric user ID too large

CRC: 3349664934
MD5: b7af1d2485870cd9c4f24c559da617cb

Self-extractable archive "release/makeself-2.4.5.run" successfully created.
~/src/makeself ((64674c74))  
❯❯  mkdir /tmp/tst && cd /tmp/tst

/tmp/tst  
❯❯  ~/src/makeself/release/makeself-2.4.5.run 
Creating directory makeself-2.4.5
Verifying archive integrity...     0% expr: division by zero
/usr/local/google/home/jackmanb/src/makeself/release/makeself-2.4.5.run: line 137: test: -lt: unary operator expected
 100%   MD5 checksums are OK. All good.
Uncompressing Makeself v2.4.5     0% expr: division by zero
/usr/local/google/home/jackmanb/src/makeself/release/makeself-2.4.5.run: line 137: test: -lt: unary operator expected
 100%  
Makeself has extracted itself

/tmp/tst  
❯❯  ls makeself-2.4.5/

So even makeself's own archive doesn't work. Then if I check out the parent commit and try again:

~/src/makeself ((64674c74))  
❯❯  git checkout HEAD^
Previous HEAD position was 64674c7 add test on Alpine and Nanoserver using busybox (#265)
HEAD is now at 5809be7 Update $USER_PWD when using --copy (fixes #262)

~/src/makeself ((5809be74))  
❯❯  make -j clean && make -j
rm -f makeself-*.run
./make-release.sh
Header is 716 lines long

WARNING: Overwriting existing file: release/makeself-2.4.5.run
About to compress 204 KB of data...
Adding files to archive named "release/makeself-2.4.5.run"...
./.gitmodules
./COPYING
./README.md
./VERSION
./makeself-header.sh
./makeself.1
./makeself.lsm
./makeself.sh
./test/appendtest
./test/bashunit/.git
./test/bashunit/LICENSE
./test/bashunit/README.md
./test/bashunit/bashunit.bash
./test/bashunit/test_example
./test/corrupttest
./test/datetest
./test/extracttest
./test/infotest
./test/lsmtest
./test/secret_key.gpg
./test/signtest
./test/suidtest
./test/tarextratest
./test/variabletest
./test/whitespacelicensetest
./test/whitespacetest
CRC: 2974530869
MD5: d486ebaf826466ccb12c6400c6bc62cf

Self-extractable archive "release/makeself-2.4.5.run" successfully created.

~/src/makeself ((5809be74))  
❯❯  rm -rf /tmp/tst; mkdir /tmp/tst && cd /tmp/tst

/tmp/tst  
❯❯  ~/src/makeself/release/makeself-2.4.5.run
Creating directory makeself-2.4.5
Verifying archive integrity...  100%   MD5 checksums are OK. All good.
Uncompressing Makeself v2.4.5  100%  
Makeself has extracted itself

/tmp/tst  
❯❯  ls makeself-2.4.5/
COPYING  makeself.1  makeself-header.sh*  makeself.lsm  makeself.sh*  README.md  test/  VERSION

... it works.