diff options
Diffstat (limited to '')
-rw-r--r-- | editors/patch.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/editors/patch.c b/editors/patch.c index 9a3740882..337d1bbad 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -54,29 +54,17 @@ 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) *temp = 0; |
63 | line_ptr = strchr(filename_start_ptr, '\t'); | ||
64 | if (!line_ptr) { | ||
65 | bb_perror_msg("Malformed line %s", line); | ||
66 | return(NULL); | ||
67 | } | ||
68 | *line_ptr = '\0'; | ||
69 | } | ||
70 | 63 | ||
71 | /* Skip over (patch_level) number of leading directories */ | 64 | /* skip over (patch_level) number of leading directories */ |
72 | for (i = 0; i < patch_level; i++) { | 65 | for (i = 0; i < patch_level; i++) { |
73 | char *dirname_ptr; | 66 | if(!(temp = strchr(filename_start_ptr, '/'))) break; |
74 | 67 | filename_start_ptr = temp + 1; | |
75 | dirname_ptr = strchr(filename_start_ptr, '/'); | ||
76 | if (!dirname_ptr) { | ||
77 | break; | ||
78 | } | ||
79 | filename_start_ptr = dirname_ptr + 1; | ||
80 | } | 68 | } |
81 | 69 | ||
82 | return(bb_xstrdup(filename_start_ptr)); | 70 | return(bb_xstrdup(filename_start_ptr)); |