Bug 76708

Summary: lha fails with segm fault on any file archiving
Product: [Retired] Red Hat Linux Reporter: Sysoltsev Slawa <vyatcheslav.sysoltsev>
Component: lhaAssignee: Than Ngo <than>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 7.2   
Target Milestone: ---   
Target Release: ---   
Hardware: ia64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-07-07 13:10:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sysoltsev Slawa 2002-10-25 06:48:17 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

Description of problem:
trying to do:
lha a archive SomeFile
I receive segmentation fault in lha.
Stack backtrace is:
#0  cleaning_files (v_filec=0x60000000000027b4, v_filev=0x6000000000002798) at 
lharc.c:578
#1  0x400000000000b620 in cmd_add () at lhadd.c:523
#2  0x4000000000003820 in main (argc=4, argv=0x80000fffffffb748) at lharc.c:289

Problem is that you guys use malloc/xmalloc routines in src/lharc.c implicitly, 
i.e. without prototyping. Declared implicitly, int return type for function is 
assumed, while void * is needed. As int is only 32 bits width while void * is 
64 bit width on IA64, result from malloc is cut to 32 bits to fit in int. As a 
result bad pointer produced and any dereferencing of it causes segmentation 
violation.

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


How reproducible:
Always

Steps to Reproduce:
1. echo > SomeFile
2. lha a archive SomeFile

	

Actual Results:  Segmentation fault (core dumped)

Expected Results:  archive archive.lzh in current directory

Additional info:

gcc warns about pointer truncation compiling source:
lharc.c: In function `main':
lharc.c:256: warning: cast to pointer from integer of different size
lharc.c:264: warning: cast to pointer from integer of different size
lharc.c:270: warning: cast to pointer from integer of different size
You could pay attention to it testing the application (if you have done it at 
all of course).
Workaround to get more workable lha is to include <stdlib.h> to lharc.h file.
By the way gcc still warns about pointer truncation in another source files - 
you should pay attention to it too.

Comment 1 Than Ngo 2003-07-07 13:10:18 UTC
it should not use malloc routine from src/lharc.c. it seems that the lha-1.14 is
fixed in RHL 9. I will do errata soon.