Remove some possible buffer overflows
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13903 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
475c6c6ce0
commit
e450d4ebac
1 changed files with 19 additions and 18 deletions
|
|
@ -430,7 +430,7 @@ int SwigType_isreference(const SwigType *t) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
|
SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
|
||||||
char temp[256], newq[256];
|
String *newq;
|
||||||
int sz, added = 0;
|
int sz, added = 0;
|
||||||
char *q, *cqual;
|
char *q, *cqual;
|
||||||
|
|
||||||
|
|
@ -438,8 +438,9 @@ SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
|
||||||
cqual = Char(qual);
|
cqual = Char(qual);
|
||||||
|
|
||||||
if (!(strncmp(c, "q(", 2) == 0)) {
|
if (!(strncmp(c, "q(", 2) == 0)) {
|
||||||
sprintf(temp, "q(%s).", cqual);
|
String *temp = NewStringf("q(%s).", cqual);
|
||||||
Insert(t, 0, temp);
|
Insert(t, 0, temp);
|
||||||
|
Delete(temp);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -449,40 +450,40 @@ SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
|
||||||
order */
|
order */
|
||||||
|
|
||||||
sz = element_size(c);
|
sz = element_size(c);
|
||||||
strncpy(temp, c, (sz < 256) ? sz : 256);
|
|
||||||
|
|
||||||
if (strstr(temp, cqual)) {
|
if (strstr(c, cqual)) {
|
||||||
/* Qualifier already added */
|
/* Qualifier already added */
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the qualifier to the existing list. */
|
/* Add the qualifier to the existing list. */
|
||||||
|
|
||||||
strcpy(newq, "q(");
|
newq = NewString("q(");
|
||||||
q = temp + 2;
|
q = c + 2;
|
||||||
q = strtok(q, " ).");
|
q = strtok(q, " ).");
|
||||||
while (q) {
|
while (q) {
|
||||||
if (strcmp(cqual, q) < 0) {
|
if (strcmp(cqual, q) < 0) {
|
||||||
/* New qualifier is less that current qualifier. We need to insert it */
|
/* New qualifier is less that current qualifier. We need to insert it */
|
||||||
strcat(newq, cqual);
|
Append(newq, cqual);
|
||||||
strcat(newq, " ");
|
Append(newq, " ");
|
||||||
strcat(newq, q);
|
Append(newq, q);
|
||||||
added = 1;
|
added = 1;
|
||||||
} else {
|
} else {
|
||||||
strcat(newq, q);
|
Append(newq, q);
|
||||||
}
|
}
|
||||||
q = strtok(NULL, " ).");
|
q = strtok(NULL, " ).");
|
||||||
if (q) {
|
if (q) {
|
||||||
strcat(newq, " ");
|
Append(newq, " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!added) {
|
if (!added) {
|
||||||
strcat(newq, " ");
|
Append(newq, " ");
|
||||||
strcat(newq, cqual);
|
Append(newq, cqual);
|
||||||
}
|
}
|
||||||
strcat(newq, ").");
|
Append(newq, ").");
|
||||||
Delslice(t, 0, sz);
|
Delslice(t, 0, sz);
|
||||||
Insert(t, 0, newq);
|
Insert(t, 0, newq);
|
||||||
|
Delete(newq);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -590,11 +591,11 @@ int SwigType_ismemberpointer(const SwigType *t) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) {
|
SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) {
|
||||||
char temp[512];
|
String *temp = NewString("a(");
|
||||||
strcpy(temp, "a(");
|
Append(temp, size);
|
||||||
strcat(temp, Char(size));
|
Append(temp, ").");
|
||||||
strcat(temp, ").");
|
|
||||||
Insert(t, 0, temp);
|
Insert(t, 0, temp);
|
||||||
|
Delete(temp);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue