Skip to content

Commit e0cd72c

Browse files
committed
Fix file name null termination issue
1 parent ae19703 commit e0cd72c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

splitfs/fileops_nvp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,7 @@ void nvp_free_dr_mmaps()
16191619
unsigned long offset_in_page = 0;
16201620
struct free_dr_pool *temp_free_pool_of_dr_mmaps;
16211621
int i = 0;
1622+
ssize_t file_name_size = 0;
16221623

16231624
while( lfds711_queue_umm_dequeue(&qs, &qe) ) {
16241625
temp_free_pool_of_dr_mmaps = LFDS711_QUEUE_UMM_GET_VALUE_FROM_ELEMENT( *qe );
@@ -1629,8 +1630,10 @@ void nvp_free_dr_mmaps()
16291630
char fd_str[256];
16301631
char new_path[256];
16311632
sprintf(fd_str, "/proc/self/fd/%d", temp_free_pool_of_dr_mmaps->dr_fd);
1632-
if (readlink(fd_str, new_path, sizeof(new_path)) == -1)
1633+
file_name_size = readlink(fd_str, new_path, sizeof(new_path));
1634+
if (file_name_size == -1)
16331635
assert(0);
1636+
new_path[file_name_size] = '\0';
16341637

16351638
close(temp_free_pool_of_dr_mmaps->dr_fd);
16361639

@@ -1651,8 +1654,10 @@ void nvp_free_dr_mmaps()
16511654
char fd_str[256];
16521655
char new_path[256];
16531656
sprintf(fd_str, "/proc/self/fd/%d", temp_free_pool_of_dr_mmaps->dr_fd);
1654-
if (readlink(fd_str, new_path, sizeof(new_path)) == -1)
1657+
file_name_size = readlink(fd_str, new_path, sizeof(new_path));
1658+
if (readlink(file_name_size == -1)
16551659
assert(0);
1660+
new_path[file_name_size] = '\0';
16561661

16571662
close(temp_free_pool_of_dr_mmaps->dr_fd);
16581663

0 commit comments

Comments
 (0)