Bug 62981 - misused option causes segfault
misused option causes segfault
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: patch (Show other bugs)
7.2
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-04-08 17:13 EDT by Peter Bieringer
Modified: 2007-04-18 12:41 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-04-09 09:36:18 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Peter Bieringer 2002-04-08 17:13:28 EDT
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 09:19:42 EDT
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 09:36:13 EDT
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 09:42:56 EDT
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.