oaf patch ...




	Just committed this to improve tests, and disallow certain
characters from oafiid's such as "[],!#|".

	Regards,

		Michael.

-- 
 mmeeks@gnu.org  <><, Pseudo Engineer, itinerant idiot
? mjs
? docs/oaf-naming.txt
? liboaf/a.out
? liboaf/a.c
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/oaf/ChangeLog,v
retrieving revision 1.33
diff -u -r1.33 ChangeLog
--- ChangeLog	2000/07/03 22:06:47	1.33
+++ ChangeLog	2000/07/05 21:41:13
@@ -1,3 +1,23 @@
+2000-07-05  Michael Meeks  <michael@helixcode.com>
+
+	* test/oaf-test-client.c (main): update to return a value
+	dependant on tests passing.
+
+	* test/Makefile.am (TESTS): add oaf-test-client
+
+	* oafd/od-load.c (od_validate_iid): update to make Maciej
+	happy.
+
+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-07-03  Maciej Stachowiak  <mjs@eazel.com>
 
 	* NEWS: Updated for 0.4.0
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/07/05 21:41:14
@@ -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,24 @@
 	}
 }
 
+static gboolean
+od_validate_iid (const char *iid)
+{
+        int i;
+
+        for (i = 0; iid && iid [i]; i++) {
+                char c = iid [i];
+
+                if (c == ',' || c == '[' || c == ']' ||
+                    /* Reserved for future expansion */
+                    c == '!' || c == '#' || c == '|')
+                        return FALSE;
+
+        }
+
+        return TRUE;
+}
+
 OAF_ServerInfo *
 OAF_ServerInfo_load (char **dirs,
 		     CORBA_unsigned_long *nservers,
@@ -187,7 +206,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 +218,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/Makefile.am
===================================================================
RCS file: /cvs/gnome/oaf/test/Makefile.am,v
retrieving revision 1.9
diff -u -r1.9 Makefile.am
--- test/Makefile.am	2000/05/29 13:07:28	1.9
+++ test/Makefile.am	2000/07/05 21:41:14
@@ -27,3 +27,5 @@
 emptydata_DATA=$(oaffiles)
 
 EXTRA_DIST=empty.idl $(oaffiles)
+
+TESTS=oaf-test-client
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/07/05 21:41:15
@@ -4,6 +4,8 @@
 #include <stdlib.h>
 #include "empty.h"
 
+#define TOTAL_TEST_SCORE 9
+
 CORBA_Object name_service = CORBA_OBJECT_NIL;
 
 static char *
@@ -69,7 +71,7 @@
         return FALSE;
 }
 
-static void
+static int
 test_empty (CORBA_Object obj, CORBA_Environment *ev, const char *type)
 {
         Empty_doNothing (obj, ev);
@@ -77,14 +79,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 +101,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 +124,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 +142,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,16 +160,23 @@
         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 == TOTAL_TEST_SCORE? "All": "some failures");
 
 	CORBA_exception_free (&ev);
 
-	return 0;
+        if (passed == TOTAL_TEST_SCORE)
+                return 0;
+        else
+                return 1;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]