Oaf character set limiation...
- From: Michael Meeks <michael helixcode com>
- To: Maciej Stachowiak <mjs eazel com>
- Cc: gnome-components-list gnome org
- Subject: Oaf character set limiation...
- Date: Wed, 21 Jun 2000 10:58:42 -0400 (EDT)
Hi there,
This patch limits the character set allowed in an oafiid, which as
previously decided is useful for monikers. It also stops horrendous things
happening when a ',' is inserted into an oafiid. none of the oafinfo files
on my machine cause it grief which is good.
Regards,
Michael.
--
mmeeks@gnu.org <><, Pseudo Engineer, itinerant idiot
? mjs
? oaf.spec
? docs/oaf-naming.txt
? liboaf/a.out
? liboaf/a.c
? test/oaf-slay
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/oaf/ChangeLog,v
retrieving revision 1.28
diff -u -r1.28 ChangeLog
--- ChangeLog 2000/06/18 00:37:32 1.28
+++ ChangeLog 2000/06/21 14:55:47
@@ -1,3 +1,13 @@
+2000-06-21 Michael Meeks <michael@helixcode.com>
+
+ * test/oaf-test-client.c (test_empty): add return value.
+ (main): make it more obvious if everything succeeded.
+
+2000-06-05 Michael Meeks <michael@helixcode.com>
+
+ * oafd/od-load.c (od_validate_iid): implement.
+ (OAF_ServerInfo_load): check iid's for conformance.
+
2000-06-17 Dan Winship <danw@helixcode.com>
* configure.in: Make sure the user has the special post-0.5.1
Index: oafd/od-load.c
===================================================================
RCS file: /cvs/gnome/oaf/oafd/od-load.c,v
retrieving revision 1.10
diff -u -r1.10 od-load.c
--- oafd/od-load.c 2000/05/16 00:34:56 1.10
+++ oafd/od-load.c 2000/06/21 14:55:47
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
#include "oafd.h"
#include <stdlib.h>
+#include <ctype.h>
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
@@ -131,6 +132,23 @@
}
}
+static gboolean
+od_validate_iid (const char *iid)
+{
+ int i;
+
+ for (i = 0; iid && iid [i]; i++) {
+ char c = iid [i];
+
+ if (!isalnum (c) && c != '.' &&
+ c != '-' && c != '_' && c != ':') {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
OAF_ServerInfo *
OAF_ServerInfo_load (char **dirs,
CORBA_unsigned_long *nservers,
@@ -187,7 +205,7 @@
? doc->root->childs : doc->root);
NULL != curnode; curnode = curnode->next) {
OAF_ServerInfo *new_ent;
- char *ctmp;
+ char *ctmp, *iid;
if (curnode->type != XML_ELEMENT_NODE)
continue;
@@ -199,14 +217,20 @@
if (strcasecmp (curnode->name, "oaf_server"))
continue;
+
+ iid = xmlGetProp (curnode, "iid");
+
+ if (!od_validate_iid (iid)) {
+ g_print ("IID '%s' contains illegal characters; discarding\n", iid);
+ free (iid);
+ continue;
+ }
- new_ent =
- oaf_alloca (sizeof (OAF_ServerInfo));
+ new_ent = oaf_alloca (sizeof (OAF_ServerInfo));
memset (new_ent, 0, sizeof (OAF_ServerInfo));
- ctmp = xmlGetProp (curnode, "iid");
- new_ent->iid = CORBA_string_dup (ctmp);
- free (ctmp);
+ new_ent->iid = CORBA_string_dup (iid);
+ free (iid);
ctmp = xmlGetProp (curnode, "type");
new_ent->server_type =
Index: test/oaf-test-client.c
===================================================================
RCS file: /cvs/gnome/oaf/test/oaf-test-client.c,v
retrieving revision 1.8
diff -u -r1.8 oaf-test-client.c
--- test/oaf-test-client.c 2000/06/02 23:03:55 1.8
+++ test/oaf-test-client.c 2000/06/21 14:55:47
@@ -69,7 +69,7 @@
return FALSE;
}
-static void
+static int
test_empty (CORBA_Object obj, CORBA_Environment *ev, const char *type)
{
Empty_doNothing (obj, ev);
@@ -77,14 +77,17 @@
if (ev->_major != CORBA_NO_EXCEPTION) {
g_warning ("Call failed: %s\n",
oaf_exception_id (ev));
+ return 0;
} else {
fprintf (stderr, "Test %s succeeded\n", type);
+ return 1;
}
}
int
main (int argc, char *argv[])
{
+ int passed = 0;
CORBA_Object obj;
CORBA_Environment ev;
@@ -96,19 +99,19 @@
obj = oaf_activate ("repo_ids.has('IDL:Empty:1.0')", NULL, 0, NULL,
&ev);
if (test_object (obj, &ev, "by query")) {
- test_empty (obj, &ev, "by query");
+ passed += test_empty (obj, &ev, "by query");
}
obj = oaf_activate_from_id ("OAFIID:Empty:19991025", 0, NULL, &ev);
if (test_object (obj, &ev, "from id")) {
- test_empty (obj, &ev, "from id");
+ passed += test_empty (obj, &ev, "from id");
}
obj = oaf_activate_from_id ("OAFAID:[OAFIID:Empty:19991025]", 0, NULL, &ev);
if (test_object (obj, &ev, "from aid")) {
- test_empty (obj, &ev, "from aid");
+ passed += test_empty (obj, &ev, "from aid");
}
@@ -119,9 +122,11 @@
} else {
fprintf (stderr, "passed 1 ('%s')", oaf_exception_id (&ev));
CORBA_exception_free (&ev);
+ passed++;
}
if (test_oafd (&ev, "with broken factory link")) {
fprintf (stderr, ", passed 2");
+ passed++;
} else {
fprintf (stderr, ", failed 2");
}
@@ -135,9 +140,11 @@
} else {
fprintf (stderr, "passed 1 ('%s')", oaf_exception_id (&ev));
CORBA_exception_free (&ev);
+ passed++;
}
if (test_oafd (&ev, "with broken factory link")) {
fprintf (stderr, ", passed 2");
+ passed++;
} else {
fprintf (stderr, ", failed 2");
}
@@ -151,14 +158,18 @@
else {
fprintf (stderr, "passed 1 ('%s')", oaf_exception_id (&ev));
CORBA_exception_free (&ev);
+ passed++;
}
if (test_oafd (&ev, "with broken factory link")) {
fprintf (stderr, ", passed 2");
+ passed++;
} else {
fprintf (stderr, ", failed 2");
}
fprintf (stderr, "\n");
+ fprintf (stderr, "\n%d tests passed (%s)\n", passed,
+ passed == 9? "All": "some failures");
CORBA_exception_free (&ev);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]