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

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-02-09 01:25:01 +0300
committerJunio C Hamano <gitster@pobox.com>2016-02-09 01:55:28 +0300
commitf58316db0ef1b25506c8cd6cc86b3071243a672a (patch)
tree968784c9eff47edb3a0b97e9e18422315ec4614c /rerere.c
parent15ed07d532db743a2a397a38bacc1f20e54b2c80 (diff)
rerere: replace strcpy with xsnprintf
This shouldn't overflow, as we are copying a sha1 hex into a 41-byte buffer. But it does not hurt to use a bound-checking function, which protects us and makes auditing for overflows easier. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'rerere.c')
-rw-r--r--rerere.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/rerere.c b/rerere.c
index 9bef24f5b29..3d0fa8f5515 100644
--- a/rerere.c
+++ b/rerere.c
@@ -50,7 +50,7 @@ static int has_rerere_resolution(const struct rerere_id *id)
static struct rerere_id *new_rerere_id_hex(char *hex)
{
struct rerere_id *id = xmalloc(sizeof(*id));
- strcpy(id->hex, hex);
+ xsnprintf(id->hex, sizeof(id->hex), "%s", hex);
return id;
}
@@ -900,7 +900,7 @@ int rerere_forget(struct pathspec *pathspec)
static struct rerere_id *dirname_to_id(const char *name)
{
static struct rerere_id id;
- strcpy(id.hex, name);
+ xsnprintf(id.hex, sizeof(id.hex), "%s", name);
return &id;
}