Commit b8ec9be1 authored by Ken Martin's avatar Ken Martin Committed by Kitware Robot
Browse files

Merge topic 'address_gcc_strncpy_warnings'

c12e9c1a

 gcc warns on strncpy that is short of the term char
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !4488
parents d97b99d0 c12e9c1a
Pipeline #109174 passed with stage
in 0 seconds
......@@ -1185,7 +1185,8 @@ void preSig(const char *arg)
if (n > 0)
{
memmove(&signature[n], signature, sigLength);
strncpy(signature, arg, n);
// we intentionally do not want /0 here
memmove(signature, arg, n);
sigLength += n;
}
signature[sigLength] = '\0';
......@@ -1201,10 +1202,9 @@ void postSig(const char *arg)
checkSigSize(n);
if (n > 0)
{
strncpy(&signature[sigLength], arg, n);
strncpy(&signature[sigLength], arg, n + 1);
sigLength += n;
}
signature[sigLength] = '\0';
}
}
......
......@@ -1755,8 +1755,8 @@ const char *preproc_find_include_file(
return NULL;
}
}
strncpy(output, directory, j);
// memmove as we intentionally are not copying /0
memmove(output, directory, j);
if (directory[j-1] != '/') { output[j++] = '/'; }
strncpy(&output[j], filename, m);
output[j+m] = '\0';
......@@ -4207,7 +4207,8 @@ const char *vtkParsePreprocess_ExpandMacro(
rp = (char *)malloc(rs);
memcpy(rp, tp, i);
}
strncpy(&rp[i], text, l);
// memmove as we intentionally are not copying /0
memmove(&rp[i], text, l);
vtkParsePreprocess_FreeProcessedString(info, text);
if (tp && tp != stack_rp)
{
......@@ -4383,7 +4384,8 @@ const char *vtkParsePreprocess_ProcessString(
rp = (char *)realloc(rp, rs);
}
}
strncpy(&rp[i], processed, l);
// memmove as we intentionally are not copying /0
memmove(&rp[i], processed, l);
}
if (processed != expansion)
{
......
......@@ -460,8 +460,7 @@ static char **append_namespace_contents(
new_scope[n++] = ':';
new_scope[n++] = ':';
}
strncpy(&new_scope[n], data->Name, m);
new_scope[n+m] = '\0';
strncpy(&new_scope[n], data->Name, m + 1);
scope = new_scope;
}
else if (m)
......
......@@ -155,9 +155,8 @@ static void vtkWPString_Append(
str->str = (char *)realloc(str->str, str->maxlen);
}
strncpy(&str->str[str->len], text, n);
strncpy(&str->str[str->len], text, n + 1);
str->len += n;
str->str[str->len] = '\0';
}
/* -- add a char ---------- */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment