diff options
author | Tharre <tharre3@gmail.com> | 2016-10-26 00:46:05 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2016-10-26 00:46:17 +0200 |
commit | d0b51f93d00c600d2c2e5480b1fd1d8d32bb1fdc (patch) | |
tree | f64d93f1159abe2757c99f291d81b3ec125b15ca /src | |
parent | 5f3cab5c51ddf78a907499bf3bc19f0c2def4735 (diff) | |
download | redo-d0b51f93d00c600d2c2e5480b1fd1d8d32bb1fdc.tar.gz redo-d0b51f93d00c600d2c2e5480b1fd1d8d32bb1fdc.tar.xz redo-d0b51f93d00c600d2c2e5480b1fd1d8d32bb1fdc.zip |
Make sha1_to_hex() return a null-terminated string
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/build.c b/src/build.c index bd4da3c..db73d4a 100644 --- a/src/build.c +++ b/src/build.c @@ -404,6 +404,7 @@ static void update_dep_info(dep_info *dep, const char *target) { fclose(fp); } +/* Requires a buffer of at least 20*2+1 = 41 bytes */ static void sha1_to_hex(const unsigned char *sha1, char *buf) { static const char hex[] = "0123456789abcdef"; @@ -412,6 +413,8 @@ static void sha1_to_hex(const unsigned char *sha1, char *buf) { *pos++ = hex[sha1[i] >> 4]; *pos = hex[sha1[i] & 0xf]; } + + buf[40] = '\0'; } static void hex_to_sha1(const char *s, unsigned char *sha1) { @@ -429,7 +432,6 @@ static void write_dep_information(dep_info *dep) { char hash[41]; sha1_to_hex(dep->hash, hash); - hash[40] = '\0'; char *flags = dep->flags & DEP_SOURCE ? "s" : "l"; int magic = atoi(getenv("REDO_MAGIC")); |