summaryrefslogtreecommitdiff
path: root/convert.c
diff options
context:
space:
mode:
authorHenrik Grubbström <grubba@grubba.org>2010-04-06 12:46:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-04-11 04:45:00 (GMT)
commita9f3049f6c152d4e6c26b15f7eeb08660aaadca3 (patch)
tree483205ed0d4068abeb176ff04591ac263b52f44b /convert.c
parentb9aa901856cee7ad16737343f6a372bb37871258 (diff)
downloadgit-a9f3049f6c152d4e6c26b15f7eeb08660aaadca3.zip
git-a9f3049f6c152d4e6c26b15f7eeb08660aaadca3.tar.gz
git-a9f3049f6c152d4e6c26b15f7eeb08660aaadca3.tar.bz2
convert: Safer handling of $Id$ contraction.
The code to contract $Id:xxxxx$ strings could eat an arbitrary amount of source text if the terminating $ was lost. It now refuses to contract $Id:xxxxx$ strings spanning multiple lines. Signed-off-by: Henrik Grubbström <grubba@grubba.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'convert.c')
-rw-r--r--convert.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/convert.c b/convert.c
index 4f8fcb7..239fa0a 100644
--- a/convert.c
+++ b/convert.c
@@ -425,6 +425,8 @@ static int count_ident(const char *cp, unsigned long size)
cnt++;
break;
}
+ if (ch == '\n')
+ break;
}
}
return cnt;
@@ -455,6 +457,11 @@ static int ident_to_git(const char *path, const char *src, size_t len,
dollar = memchr(src + 3, '$', len - 3);
if (!dollar)
break;
+ if (memchr(src + 3, '\n', dollar - src - 3)) {
+ /* Line break before the next dollar. */
+ continue;
+ }
+
memcpy(dst, "Id$", 3);
dst += 3;
len -= dollar + 1 - src;
@@ -514,6 +521,11 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
break;
}
+ if (memchr(src + 3, '\n', dollar - src - 3)) {
+ /* Line break before the next dollar. */
+ continue;
+ }
+
len -= dollar + 1 - src;
src = dollar + 1;
} else {