Skip to content

Commit df1733d

Browse files
committed
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.
1 parent 8533c80 commit df1733d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/checkout/index.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,11 @@ void test_checkout_index__honor_coresymlinks_default(void)
185185
check_file_contents("./symlink/link_to_new.txt", "new.txt");
186186
} else {
187187
char link_data[1024];
188-
size_t link_size = 1024;
188+
int link_size = 1024;
189189

190190
link_size = p_readlink("./symlink/link_to_new.txt", link_data, link_size);
191+
cl_assert(link_size >= 0);
192+
191193
link_data[link_size] = '\0';
192194
cl_assert_equal_i(link_size, strlen("new.txt"));
193195
cl_assert_equal_s(link_data, "new.txt");

0 commit comments

Comments
 (0)