Bug 62981

Summary: misused option causes segfault
Product: [Retired] Red Hat Linux Reporter: Peter Bieringer <pb>
Component: patchAssignee: Tim Waugh <twaugh>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: jakub
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-04-09 13:36: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 Peter Bieringer 2002-04-08 21:13:28 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.78 [en] (X11; U; Linux 2.4.17-0.18 i686)

Description of problem:
Loks like option handling isn't proper

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


How reproducible:
Always

Steps to Reproduce:
$ patch -V test
Segmentation fault

$ patch -v
patch 2.5.4


Expected Results:  Not a segfault

Additional info:

Comment 1 Tim Waugh 2002-04-09 13:19:42 UTC
This boils down to the following test case:   
   
a.c:   
==>   
char program_name[] = "patch";   
<==   
   
b.c:   
==>   
#include <stdio.h>   
   
extern char *program_name;   
   
int main ()   
{   
        fprintf (stderr, "%s\n", program_name);   
}   
<==  
  
which also segfaults.  Jakub, is there any chance this is a compiler problem?

Comment 2 Jakub Jelinek 2002-04-09 13:36:13 UTC
No, it is a common programming bug.
char program_name[] = "patch";
is not equal to
char *program_name = "patch";
in C, likewise
extern char program_name[];
is not equal to
extern char *program_name;
The two must agree.
in the former case program_name symbol points to 'p' letter in "patch", in the
latter case program_name symbol points to a pointer which points to "patch".

Comment 3 Tim Waugh 2002-04-09 13:42:56 UTC
Okay, thanks.  Fixed package is 2.5.4-12.