* We don't accept absolute paths (/dev/null) as possibly valid
*/
if (name == line+1)
return NULL;
/*
* Accept a name only if it shows up twice, exactly the same
* form.
*/
for (len = 0 ; ; len++) {
char c = name[len];
switch (c) {
default:
continue;
case '\n':
break;
case '\t': case ' ':
second = name+len;
for (;;) {
char c = *second++;
if (c == '\n')
return NULL;
if (c == '/')
break;
}
if (!memcmp(name, second, len)) {
char *ret = xmalloc(len + 1);
memcpy(ret, name, len);
ret[len] = 0;
return ret;
}
}
}
return NULL;
}
/* Verify that we recognize the lines following a git header */
static int parse_git_header(char *line, int len, unsigned int size, struct patch *patch)
{
@ -345,6 +401,14 @@ static int parse_git_header(char *line, int len, unsigned int size, struct patch
@@ -345,6 +401,14 @@ static int parse_git_header(char *line, int len, unsigned int size, struct patch
patch->is_new = 0;
patch->is_delete = 0;
/*
* Some things may not have the old name in the
* rest of the headers anywhere (pure mode changes,
@ -494,7 +558,8 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
@@ -494,7 +558,8 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
int git_hdr_len = parse_git_header(line, len, size, patch);