[Openais] Patch for more graceful error handling w/ AMF
Steven Dake
sdake at redhat.com
Wed Sep 19 22:48:01 PDT 2007
On Wed, 2007-09-19 at 16:27 -0700, Drew Moseley wrote:
> 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 inline thanks for taking the time to make a patch...
>
> 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 and name2 should never be null. If they are there is a bug in the
code elsewhere that should be fixed. Do you have a test case for the
crash related to this problem or a stack backtrace with an assertion
such as
assert (name1);
assert (name2);
> 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;
> +
same comment above about assertions here ^^
> /* 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;
> }
This part looks good and fixes a problem i have been looking at. This
part of the patch has been merged.
Thanks
-steve
> else {
> assert (0);
>
> _______________________________________________
> Openais mailing list
> Openais at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/openais
More information about the Openais
mailing list