Bug 7916

Summary: patch command seg faults on malformed patch
Product: Busybox Reporter: Jim Keniston <jkenisto>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.22.x   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: suggested fix

Description Jim Keniston 2015-03-10 23:12:36 UTC
Created attachment 5916 [details]
suggested fix

The patch applet dies with a SEGV when presented with the following corrupted patch.  (Note the missing hyphen on line 1.)
-- dwarves.orig 2015-02-25 01:45:27.753000000 +0000
+++ dwarves     2015-02-25 01:46:08.199000000 +0000
@@ -1,7 +1,7 @@
 Bashful
 Doc
 Dopey
-Grouchy
+Grumpy
 Happy
 Sleepy
 Sneezy

For comparison, GNU patch silently does what's apparently wanted, based on the "+++" line.

The attached patch fixes this bug.
Comment 1 Denys Vlasenko 2015-03-11 17:09:38 UTC
Fixed in git. Thanks!