Bug 668

Summary: f=fopen(fname,a) causes core dump when fname contains '\n'
Product: [Retired] Red Hat Linux Reporter: allsupjd
Component: glibcAssignee: Cristian Gafton <gafton>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5.1   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-01-04 17:52:00 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 allsupjd 1999-01-02 15:11:58 UTC
Example program

--------------------=[ fopenbug.c ]=---------------------

#include <stdio.h>

int main()
{
  FILE * f;
  f = fopen("/etc/hosts\n","r");
  fclose(f);
}

---------------------------------------------------------

Upon executing, gives
Segmentation fault(core dumped)

GCC as per RH5.1, GLIBC as per RH5.1

Potentially, this could be used to crash applications
that take filenames without filtering them -- I haven't
investigated further, but attacks may be possible.

Comment 1 David Lawrence 1999-01-03 21:37:59 UTC
I was able to replicate the problem. It has been assigned to a
developer for further review.

Comment 2 Cristian Gafton 1999-01-04 17:52:59 UTC
Invalid chars in fname will yield an unspecified behavior (Single Unix
Specs ver 2). Segfault is a perfectly valid "unspecified behavior" in
this case.