HDFS-15922. Use memcpy for copying non-null terminated string in jni_helper.c (#2818)

This commit is contained in:
Gautham B A 2021-03-26 21:56:35 +05:30 committed by GitHub
parent 19e418c10d
commit 1fed18bb2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -422,9 +422,9 @@ static ssize_t wildcard_expandPath(const char* path, char* expanded)
if (expanded != NULL) {
// pathLength includes an extra '.'
strncpy(dest, path, pathLength-1);
memcpy(dest, path, pathLength - 1);
dest += pathLength - 1;
strncpy(dest, filename, filenameLength);
memcpy(dest, filename, filenameLength);
dest += filenameLength;
*dest = PATH_SEPARATOR;
dest++;
@ -536,7 +536,7 @@ static ssize_t getClassPath_helper(const char *classpath, char* expandedClasspat
// +1 for path separator or null terminator
length += tokenlen + 1;
if (expandedCP_curr != NULL) {
strncpy(expandedCP_curr, cp_token, tokenlen);
memcpy(expandedCP_curr, cp_token, tokenlen);
expandedCP_curr += tokenlen;
*expandedCP_curr = PATH_SEPARATOR;
expandedCP_curr++;