From: <svn...@op...> - 2009-03-31 18:30:07
|
Author: scriptor Date: Tue Mar 31 20:30:03 2009 New Revision: 5497 URL: http://www.opensync.org/changeset/5497 Log: The LDAP format plugin gets sometimes called with an empty input (inpsize = 0). Prepared for debugging this: abort() is now called in this situation. This bug seems to occur with objtype event and todo, only. Modified: plugins/ldap-sync/src/ldap_format.c Modified: plugins/ldap-sync/src/ldap_format.c ============================================================================== --- plugins/ldap-sync/src/ldap_format.c Tue Mar 31 20:28:54 2009 (r5496) +++ plugins/ldap-sync/src/ldap_format.c Tue Mar 31 20:30:03 2009 (r5497) @@ -4605,13 +4605,18 @@ // We do not really know, what input exactly is. So any cast is dangerous. // It SHOULD be a glist_container. Well, who knows... if (inpsize < sizeof(glist_container)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: inpsize = %i\n", __FILE__, __LINE__, inpsize); - goto error; + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: inpsize = %i. Calling abort()\n", __FILE__, __LINE__, inpsize); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: inpsize = %i. Calling abort()\n", __FILE__, __LINE__, inpsize); + ldap_plugin_printf("%s:%i: ERROR: inpsize = %i. Calling abort()\n", __FILE__, __LINE__, inpsize); + + abort(); + +// goto error; } if (inpsize != sizeof(glist_container)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container.\n", __FILE__, __LINE__); + // osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container.\n", __FILE__, __LINE__); osync_trace(TRACE_ERROR, "%s:%i: What is input? inpsize = %i", __FILE__, __LINE__, inpsize); @@ -4623,6 +4628,49 @@ osync_trace(TRACE_ERROR, "%s:%i: input looks like an ldap_entry.", __FILE__, __LINE__); } else if (inpsize == osync_xmlformat_size()) { osync_trace(TRACE_ERROR, "%s:%i: input looks like an OsyncXMLFormat.\n", __FILE__, __LINE__); + + +#ifdef CALL_ABORT + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container. Looks like an OSyncXMLFormat.\n", __FILE__, __LINE__); + osync_trace(TRACE_ERROR, "%s:%i: Where does that come from? Calling abort().", __FILE__, __LINE__); + ldap_plugin_printf("%s:%i: Where does that come from? Calling abort().", __FILE__, __LINE__); + fprintf(stderr, "%s:%i: Where does that come from? Calling abort().\n\n", __FILE__, __LINE__); + fflush(stderr); + abort(); + +#else + osync_assert(input); + osync_trace(TRACE_INTERNAL, "%s:%i: We can handle this. If you prefer getting a core dump, define CALL_ABORT in ldap_plugin.h and recompile the LDAP format plugin.", __FILE__, __LINE__); + + + + if (!osync_xmlformat_assemble((OSyncXMLFormat *)input, (char **) &xmlbuff, (unsigned int *)&size)) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container. Looks like an OSyncXMLFormat.\n", __FILE__, __LINE__); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: osync_xmlformat_assemble() has failed for an unknown reason. Giving up.\n", __FILE__, __LINE__); + goto error; + } + + if (xmlbuff == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container. Looks like an OSyncXMLFormat.\n", __FILE__, __LINE__); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: xmlbuff = NULL. osync_xmlformat_assemble() must have failed for an unknown reason. Giving up.\n", __FILE__, __LINE__); + + goto error; + } + + if (size < 6) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container. Looks like an OSyncXMLFormat.\n", __FILE__, __LINE__); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: size = %i. osync_xmlformat_assemble() must have failed for an unknown reason. Giving up.\n", __FILE__, __LINE__, size); + + goto error; + } + + + osync_trace(TRACE_INTERNAL, "%s:%i: This is the content of the OSyncXMLFormat:\n\"%.*s\"", __FILE__, __LINE__, size, xmlbuff); + + goto applying_stylesheet; +#endif + + } else { osync_trace(TRACE_ERROR, "%s:%i: Don't know. inpsize = %u\n", __FILE__, __LINE__, inpsize); } @@ -4667,6 +4715,8 @@ } +applying_stylesheet: + // Apply stylesheet if (!ldap_format_do_apply_stylesheet((char *)xmlbuff, size, output, outpsize, config, userdata, stylesheet_name, error)) { osync_trace(TRACE_ERROR, "%s:%i: ldap_format_do_apply_stylesheet() has failed.\n", __FILE__, __LINE__); @@ -5423,7 +5473,6 @@ #endif - if (!ldap_format_do_conv_ldap_to_xmlformat(input, inpsize, output, outpsize, free_input, FORMAT_LDAP_NOTE, FORMAT_XMLFORMAT_NOTE, STYLESHEET_LDAP_NOTE2XMLFORMAT_NOTE, OBJECTTYPE_NOTE, config, userdata, error)) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_format_do_conv_ldap_to_xmlformat() has failed.\n", __FILE__, __LINE__); |