diff options
-rw-r--r-- | editors/patch.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/editors/patch.c b/editors/patch.c index 9a3740882..666aa73a6 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -54,29 +54,19 @@ static unsigned int copy_lines(FILE *src_stream, FILE *dest_stream, const unsign | |||
54 | 54 | ||
55 | static char *extract_filename(char *line, int patch_level) | 55 | static char *extract_filename(char *line, int patch_level) |
56 | { | 56 | { |
57 | char *filename_start_ptr = line + 4; | 57 | char *temp, *filename_start_ptr = line + 4; |
58 | int i; | 58 | int i; |
59 | 59 | ||
60 | /* Terminate string at end of source filename */ | 60 | /* Terminate string at end of source filename */ |
61 | { | 61 | temp = strchr(filename_start_ptr, '\t'); |
62 | char *line_ptr; | 62 | if (temp) |
63 | line_ptr = strchr(filename_start_ptr, '\t'); | 63 | *temp = 0; |
64 | if (!line_ptr) { | ||
65 | bb_perror_msg("Malformed line %s", line); | ||
66 | return(NULL); | ||
67 | } | ||
68 | *line_ptr = '\0'; | ||
69 | } | ||
70 | 64 | ||
71 | /* Skip over (patch_level) number of leading directories */ | 65 | /* Skip over (patch_level) number of leading directories */ |
72 | for (i = 0; i < patch_level; i++) { | 66 | for (i = 0; i < patch_level; i++) { |
73 | char *dirname_ptr; | 67 | if (!(temp = strchr(filename_start_ptr, '/'))) |
74 | |||
75 | dirname_ptr = strchr(filename_start_ptr, '/'); | ||
76 | if (!dirname_ptr) { | ||
77 | break; | 68 | break; |
78 | } | 69 | filename_start_ptr = temp + 1; |
79 | filename_start_ptr = dirname_ptr + 1; | ||
80 | } | 70 | } |
81 | 71 | ||
82 | return(bb_xstrdup(filename_start_ptr)); | 72 | return(bb_xstrdup(filename_start_ptr)); |