Skip to content

Commit 1fed18b

Browse files
HDFS-15922. Use memcpy for copying non-null terminated string in jni_helper.c (#2818)
1 parent 19e418c commit 1fed18b

File tree

1 file changed

+3
-3
lines changed
  • hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs

1 file changed

+3
-3
lines changed

hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/jni_helper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ static ssize_t wildcard_expandPath(const char* path, char* expanded)
422422

423423
if (expanded != NULL) {
424424
// pathLength includes an extra '.'
425-
strncpy(dest, path, pathLength-1);
425+
memcpy(dest, path, pathLength - 1);
426426
dest += pathLength - 1;
427-
strncpy(dest, filename, filenameLength);
427+
memcpy(dest, filename, filenameLength);
428428
dest += filenameLength;
429429
*dest = PATH_SEPARATOR;
430430
dest++;
@@ -536,7 +536,7 @@ static ssize_t getClassPath_helper(const char *classpath, char* expandedClasspat
536536
// +1 for path separator or null terminator
537537
length += tokenlen + 1;
538538
if (expandedCP_curr != NULL) {
539-
strncpy(expandedCP_curr, cp_token, tokenlen);
539+
memcpy(expandedCP_curr, cp_token, tokenlen);
540540
expandedCP_curr += tokenlen;
541541
*expandedCP_curr = PATH_SEPARATOR;
542542
expandedCP_curr++;

0 commit comments

Comments
 (0)