[Openais] Patch for more graceful error handling w/ AMF

Drew Moseley dmoseley at mvista.com
Wed Sep 19 16:27:28 PDT 2007


Below is a patch for allowing aisexec to return error codes and not
crash when AMF is disabled or misconfigured.  The changes are
fairly straight-forward and hopefully not too complicated.

These patches are against the whitetank branch but some variant of
this will likely be needed in the trunk as well.


Comments?

Drew


Index: exec/util.c
===================================================================
--- exec/util.c    (revision 1452)
+++ exec/util.c    (working copy)
@@ -50,7 +50,11 @@
  */
 int name_match(SaNameT *name1, SaNameT *name2)
 {
-    if (name1->length == name2->length) {
+    if ((name1 == NULL) && (name2 != NULL)) {
+        return 0;
+    } else if ((name2 == NULL) && (name1 != NULL)) {
+        return 0;
+    } else if (name1->length == name2->length) {
         return ((strncmp ((char *)name1->value, (char *)name2->value,
             name1->length)) == 0);
     }
Index: exec/amfcomp.c
===================================================================
--- exec/amfcomp.c    (revision 1452)
+++ exec/amfcomp.c    (working copy)
@@ -694,6 +694,9 @@
     char *ptrptr;
     char *buf;
 
+    if (cluster == NULL || name == NULL)
+        return NULL;
+
     /* malloc new buffer since strtok_r writes to its first argument */
     buf = malloc (name->length + 1);
     memcpy (buf, name->value,name ->length);
@@ -1132,6 +1135,8 @@
     } else if (comp->saAmfCompPresenceState ==
SA_AMF_PRESENCE_INSTANTIATING) {
         amf_comp_operational_state_set (comp, SA_AMF_OPERATIONAL_ENABLED);
         comp_presence_state_set (comp, SA_AMF_PRESENCE_INSTANTIATED);
+    } else if (comp->saAmfCompPresenceState ==
SA_AMF_PRESENCE_UNINSTANTIATED) {
+        return SA_AIS_ERR_INVALID_PARAM;
     }
     else {
         assert (0);



More information about the Openais mailing list