Bug 62981 - misused option causes segfault
Summary: misused option causes segfault
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: patch
Version: 7.2
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-04-08 21:13 UTC by Peter Bieringer
Modified: 2007-04-18 16:41 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2002-04-09 13:36:18 UTC
Embargoed:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.