We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1ee3c37 commit cf9196bCopy full SHA for cf9196b
src/odb.c
@@ -297,14 +297,15 @@ int git_odb__hashlink(git_oid *out, const char *path)
297
GIT_ERROR_CHECK_ALLOC(link_data);
298
299
read_len = p_readlink(path, link_data, size);
300
- link_data[size] = '\0';
301
- if (read_len != size) {
+ if (read_len == -1) {
302
git_error_set(GIT_ERROR_OS, "failed to read symlink data for '%s'", path);
303
git__free(link_data);
304
return -1;
305
}
+ GIT_ASSERT(read_len <= size);
306
+ link_data[read_len] = '\0';
307
- result = git_odb_hash(out, link_data, size, GIT_OBJECT_BLOB);
308
+ result = git_odb_hash(out, link_data, read_len, GIT_OBJECT_BLOB);
309
310
} else {
311
int fd = git_futils_open_ro(path);
0 commit comments