diff options
| author | Junio C Hamano <gitster@pobox.com> | 2014-01-10 10:32:18 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2014-01-10 10:32:18 -0800 |
| commit | 273c54f82ca6bfd1f05be3bf8961c55ba60f16e5 (patch) | |
| tree | 76cf71a350cce0307b800367985f4025813d8423 /diffcore-order.c | |
| parent | Merge branch 'cc/replace-object-info' (diff) | |
| parent | Prevent buffer overflows when path is too long (diff) | |
| download | git-273c54f82ca6bfd1f05be3bf8961c55ba60f16e5.tar.gz git-273c54f82ca6bfd1f05be3bf8961c55ba60f16e5.zip | |
Merge branch 'ap/path-max'
* ap/path-max:
Prevent buffer overflows when path is too long
Diffstat (limited to 'diffcore-order.c')
| -rw-r--r-- | diffcore-order.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/diffcore-order.c b/diffcore-order.c index 23e93852d8..50c089bb2b 100644 --- a/diffcore-order.c +++ b/diffcore-order.c @@ -73,15 +73,16 @@ struct pair_order { static int match_order(const char *path) { int i; - char p[PATH_MAX]; + static struct strbuf p = STRBUF_INIT; for (i = 0; i < order_cnt; i++) { - strcpy(p, path); - while (p[0]) { + strbuf_reset(&p); + strbuf_addstr(&p, path); + while (p.buf[0]) { char *cp; - if (!fnmatch(order[i], p, 0)) + if (!fnmatch(order[i], p.buf, 0)) return i; - cp = strrchr(p, '/'); + cp = strrchr(p.buf, '/'); if (!cp) break; *cp = 0; |
