[patch] Improve robustness when reading server info properties
- From: Gustavo Giráldez <gustavo giraldez gmx net>
- To: gnome-components-list gnome org
- Subject: [patch] Improve robustness when reading server info properties
- Date: 30 Jan 2002 23:35:22 -0300
Hi,
The following patch tries to improve robustness when reading server info
properties in bonobo-activation. Badly written properties may cause
crashes when running queries.
http://bugzilla.gnome.org/show_bug.cgi?id=70126
Any property which is missing name or type attributes is not copied to
the Bonobo_ServerInfo struct, thus causing a segfault when the
bonobo-activation-server tries to run some queries involving property
lookups. I assume the default type is string, so properties which don't
specify type are treated as strings.
HTH,
Gustavo
? xml-i18n-extract
? xml-i18n-extract.in
? xml-i18n-merge
? xml-i18n-merge.in
? xml-i18n-update
? xml-i18n-update.in
? po/po2tbl.sed
? po/po2tbl.sed.in
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/bonobo-activation/ChangeLog,v
retrieving revision 1.261
diff -u -r1.261 ChangeLog
--- ChangeLog 2002/01/25 19:28:44 1.261
+++ ChangeLog 2002/01/31 01:50:09
@@ -1,3 +1,8 @@
+2002-01-30 Gustavo Giráldez <gustavo giraldez gmx net>
+
+ * server/object-directory-load.c (od_entry_read_props): Improved
+ robustness when reading server properties.
+
2002-01-25 Alexander Shopov <al_shopov web bg>
* configure.in (ALL_LINGUAS): Added "bg" (Bulgarian).
Index: server/object-directory-load.c
===================================================================
RCS file: /cvs/gnome/bonobo-activation/server/object-directory-load.c,v
retrieving revision 1.29
diff -u -r1.29 object-directory-load.c
--- server/object-directory-load.c 2002/01/25 17:12:23 1.29
+++ server/object-directory-load.c 2002/01/31 01:50:10
@@ -46,6 +46,8 @@
Bonobo_ActivationProperty *curprop;
for (n = 0, sub = node->xmlChildrenNode; sub; sub = sub->next) {
+ char *valuestr;
+
if (sub->type != XML_ELEMENT_NODE) {
continue;
}
@@ -55,7 +57,11 @@
continue;
}
- n++;
+ valuestr = xmlGetProp (sub, "name");
+ if (valuestr != NULL) {
+ n++;
+ free (valuestr);
+ }
}
server->props._length = n;
@@ -63,17 +69,17 @@
curprop = server->props._buffer;
- for (i = 0, sub = node->xmlChildrenNode; i < n; sub = sub->next, i++) {
+ for (i = 0, sub = node->xmlChildrenNode; sub; sub = sub->next, i++) {
char *type, *valuestr;
- type = xmlGetProp (sub, "type");
- if (type == NULL) {
+ if (sub->type != XML_ELEMENT_NODE ||
+ (g_ascii_strcasecmp (sub->name, "oaf_attribute") != 0 &&
+ g_ascii_strcasecmp (sub->name, "oaf_property") != 0)) {
continue;
}
-
+
valuestr = xmlGetProp (sub, "name");
if (valuestr == NULL) {
- free (type);
continue;
}
if(valuestr[0] == '_') {
@@ -84,6 +90,8 @@
curprop->name = CORBA_string_dup (valuestr);
free (valuestr);
+ type = xmlGetProp (sub, "type");
+
if (g_ascii_strcasecmp (type, "stringv") == 0) {
int j, o;
xmlNodePtr sub2;
@@ -107,8 +115,12 @@
CORBA_sequence_CORBA_string_allocbuf (o);
for (j = 0, sub2 = sub->xmlChildrenNode;
- j < o;
- sub2 = sub2->next, j++) {
+ sub2;
+ sub2 = sub2->next) {
+ if (sub2->type != XML_ELEMENT_NODE ||
+ g_ascii_strcasecmp (sub2->name, "item") != 0) {
+ continue;
+ }
valuestr = xmlGetProp (sub2, "value");
if (valuestr) {
curprop->v._u.
@@ -122,6 +134,7 @@
value_stringv._buffer[j] =
CORBA_string_dup ("");
}
+ j++;
xmlFree (valuestr);
}
@@ -154,7 +167,8 @@
xmlFree (valuestr);
}
- free (type);
+ if (type)
+ free (type);
curprop++;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]