Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-25 00:05:48 +0300
committerJunio C Hamano <gitster@pobox.com>2015-09-25 20:18:18 +0300
commitc1fd0809174a31edd17e97c1161e01907f41a4fc (patch)
tree31191c73a687b308391c621faa6a3e66b441527f /builtin
parentaf49c6d0918bf04aad89bd885a4eef5767a33d0e (diff)
fsck: use strbuf to generate alternate directories
When fsck-ing alternates, we make a copy of the alternate directory in a fixed PATH_MAX buffer. We memcpy directly, without any check whether we are overflowing the buffer. This is OK if PATH_MAX is a true representation of the maximum path on the system, because any path here will have already been vetted by the alternates subsystem. But that is not true on every system, so we should be more careful. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fsck.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 46c7235180..a019f4a240 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -683,11 +683,12 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
prepare_alt_odb();
for (alt = alt_odb_list; alt; alt = alt->next) {
- char namebuf[PATH_MAX];
- int namelen = alt->name - alt->base;
- memcpy(namebuf, alt->base, namelen);
- namebuf[namelen - 1] = 0;
- fsck_object_dir(namebuf);
+ /* directory name, minus trailing slash */
+ size_t namelen = alt->name - alt->base - 1;
+ struct strbuf name = STRBUF_INIT;
+ strbuf_add(&name, alt->base, namelen);
+ fsck_object_dir(name.buf);
+ strbuf_release(&name);
}
}