File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ static int open_hugetlbfs(struct vmctx *ctx, int level)
119
119
strncpy (path , hugetlb_priv [level ].mount_path , MAX_PATH_LEN );
120
120
121
121
/* UUID will use 32 bytes */
122
- if (strlen (path ) + 32 > MAX_PATH_LEN ) {
122
+ if (strnlen (path , MAX_PATH_LEN ) + 32 > MAX_PATH_LEN ) {
123
123
perror ("PATH overflow" );
124
124
return - ENOMEM ;
125
125
}
@@ -298,9 +298,10 @@ static int create_hugetlb_dirs(int level)
298
298
return - EINVAL ;
299
299
}
300
300
301
- strcpy (tmp_path , path );
301
+ memset (tmp_path , '\0' , MAX_PATH_LEN );
302
+ strncpy (tmp_path , path , MAX_PATH_LEN - 1 );
302
303
303
- if (tmp_path [len - 1 ] != '/' )
304
+ if (( tmp_path [len - 1 ] != '/' ) && ( strlen ( tmp_path ) < MAX_PATH_LEN - 1 ) )
304
305
strcat (tmp_path , "/" );
305
306
306
307
len = strlen (tmp_path );
You can’t perform that action at this time.
0 commit comments