From: <svn...@op...> - 2009-04-26 20:25:17
|
Author: scriptor Date: Sun Apr 26 22:25:10 2009 New Revision: 5628 URL: http://www.opensync.org/changeset/5628 Log: Building filenames is now performed by glib functions, which seem to be a bit more platform neutral. Modified: plugins/ldap-sync/src/ldap_format.c Modified: plugins/ldap-sync/src/ldap_format.c ============================================================================== --- plugins/ldap-sync/src/ldap_format.c Sun Apr 26 22:24:26 2009 (r5627) +++ plugins/ldap-sync/src/ldap_format.c Sun Apr 26 22:25:10 2009 (r5628) @@ -1725,7 +1725,7 @@ const char *schema = NULL; xmlValidCtxtPtr xmlctx = NULL; const char *path = LDAP_PLUGIN_OPENSYNC_SCHEMASDIR; - char fullpath[65535]; + char *fullpath = NULL; struct stat stat_buffer; xmlSchemaValidCtxtPtr dtd = NULL; xmlSchemaPtr xsd = NULL; @@ -1784,11 +1784,17 @@ goto error; } - snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", path, schema); + // snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", path, schema); + fullpath = g_build_filename(path, schema, NULL); + if (fullpath == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: fullpath = NULL.", __FILE__, __LINE__); + goto error; + } errno = 0; if (stat(fullpath, &stat_buffer) == -1) { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: \"%s\" could not be found: %s\n", __FILE__, __LINE__, stylesheet_file, strerror(errno)); + goto error; } @@ -1897,6 +1903,10 @@ xsd_file = NULL; } + if (fullpath) { + g_free(fullpath); + fullpath = NULL; + } osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; @@ -1917,6 +1927,11 @@ xsd_file = NULL; } + if (fullpath) { + g_free(fullpath); + fullpath = NULL; + } + if (!osync_error_is_set(error)) osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); @@ -2171,7 +2186,7 @@ xmlChar *xmlbuffer = NULL; xmlDocPtr input_doc = NULL; int xmlbuffer_size = 0; - char fullpath[1024]; + char *fullpath = NULL; xmlDocPtr xmlcard = NULL; const char *path = NULL; struct stat stat_buffer; @@ -2282,7 +2297,12 @@ goto error; } - snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", path, stylesheet_file); + // snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", path, stylesheet_file); + fullpath = g_build_filename(path, stylesheet_file, NULL); + if (fullpath == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: fullpath = NULL.", __FILE__, __LINE__); + goto error; + } errno = 0; if (stat(fullpath, &stat_buffer) == -1) { @@ -2483,6 +2503,10 @@ input_doc = NULL; } + if (fullpath) { + g_free(fullpath); + fullpath = NULL; + } osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; @@ -2514,6 +2538,11 @@ xmlbuffer = NULL; } + if (fullpath) { + g_free(fullpath); + fullpath = NULL; + } + if (!osync_error_is_set(error)) osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); |