more fixes for security and warnings

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7009 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-02-26 20:25:10 +00:00
commit 5b74ab97a7
10 changed files with 44 additions and 34 deletions

View file

@ -110,7 +110,7 @@ PySwigObject_oct(PySwigObject *v)
char buf[100];
unsigned long x = (unsigned long)v->ptr;
if (x == 0)
strcpy(buf, "0");
strncpy(buf, "0",sizeof(buf));
else
PyOS_snprintf(buf, sizeof(buf), "0%lo", x);
return PyString_FromString(buf);
@ -392,11 +392,14 @@ PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc)
return NULL;
} else {
void *pack = malloc(size);
memcpy(pack, ptr, size);
self->pack = pack;
self->desc = desc;
self->size = size;
return (PyObject *) self;
if (pack) {
memcpy(pack, ptr, size);
self->pack = pack;
self->desc = desc;
self->size = size;
return (PyObject *) self;
}
return NULL;
}
}