[Coverity] fix issue reported for SWIG_Python_FixMethods
Fix Coverity issue reported for SWIG_Python_FixMethods: "buffer_size: Calling strncpy with a source string whose length (10 chars) is greater than or equal to the size argument (10) will fail to null-terminate buff." The issue is only reported for the "swig_ptr: " line, but for consistency we replace both occurrences of strncpy with memcpy.
This commit is contained in:
parent
e5add63548
commit
9825fcbab5
1 changed files with 2 additions and 2 deletions
|
|
@ -306,9 +306,9 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
|
||||||
char *ndoc = (char*)malloc(ldoc + lptr + 10);
|
char *ndoc = (char*)malloc(ldoc + lptr + 10);
|
||||||
if (ndoc) {
|
if (ndoc) {
|
||||||
char *buff = ndoc;
|
char *buff = ndoc;
|
||||||
strncpy(buff, methods[i].ml_doc, ldoc);
|
memcpy(buff, methods[i].ml_doc, ldoc);
|
||||||
buff += ldoc;
|
buff += ldoc;
|
||||||
strncpy(buff, "swig_ptr: ", 10);
|
memcpy(buff, "swig_ptr: ", 10);
|
||||||
buff += 10;
|
buff += 10;
|
||||||
SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
|
SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
|
||||||
methods[i].ml_doc = ndoc;
|
methods[i].ml_doc = ndoc;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue