diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2018-07-16 15:16:41 +0300 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-10-20 15:51:46 +0300 |
commit | df1733deb9eb7b4125bd994ea7b441712788e181 (patch) | |
tree | d83eb3f5341f65e7a1250a1e5d14b458f96be315 /tests/checkout/index.c | |
parent | 8533c80dfb4c09c4b19aa40756ffae99595c9b6b (diff) |
checkout tests: ensure readlink succeeds
Don't try to use `link_size` as an index into a string if `p_readlink`
returned <0. That will - obviously - fail and we'll write out of
bounds.
Diffstat (limited to 'tests/checkout/index.c')
-rw-r--r-- | tests/checkout/index.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/checkout/index.c b/tests/checkout/index.c index 452362662..270059b21 100644 --- a/tests/checkout/index.c +++ b/tests/checkout/index.c @@ -185,9 +185,11 @@ void test_checkout_index__honor_coresymlinks_default(void) check_file_contents("./symlink/link_to_new.txt", "new.txt"); } else { char link_data[1024]; - size_t link_size = 1024; + int link_size = 1024; link_size = p_readlink("./symlink/link_to_new.txt", link_data, link_size); + cl_assert(link_size >= 0); + link_data[link_size] = '\0'; cl_assert_equal_i(link_size, strlen("new.txt")); cl_assert_equal_s(link_data, "new.txt"); |