[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Fix 2441

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-01-06 10:40:53 CET

Hi All,
Slightly better fix for #2441.

With regards
Kamesh Jayachandran

[[[
Fix issue #2441, 'svnadmin load' malformed dumpfile errors are
intolerably vague

* subversion/libsvn_repos/load.c
  (contextual_error): will return a svn_error_t * indicating which
header block
  problematic header occured with a header name and a reason for failure.

]]]

Index: subversion/libsvn_repos/load.c
===================================================================
--- subversion/libsvn_repos/load.c (revision 17993)
+++ subversion/libsvn_repos/load.c (working copy)
@@ -105,6 +105,56 @@
 }
 
 
+/** This function gives a contextual clue of dump file malformed content. **/
+static svn_error_t *
+contextual_error (apr_hash_t *headers, char *key, char *reason)
+{
+ char *block=NULL;
+ if ((block = (char *)apr_hash_get (headers,
+ SVN_REPOS_DUMPFILE_REVISION_NUMBER,
+ APR_HASH_KEY_STRING)) != NULL)
+ {
+ return svn_error_createf (SVN_ERR_STREAM_MALFORMED_DATA, NULL,
+ _("Found malformed revision %s header block "
+ "near the line starting with a key %s %s "
+ "in dumpfile stream"), block, key, reason);
+ }
+ else if ((block = (char *)apr_hash_get (headers,
+ SVN_REPOS_DUMPFILE_NODE_PATH,
+ APR_HASH_KEY_STRING)) != NULL)
+ {
+ return svn_error_createf (SVN_ERR_STREAM_MALFORMED_DATA, NULL,
+ _("Found malformed node %s header block "
+ "near the line starting with a key %s %s "
+ "in dumpfile stream"), block, key, reason);
+ }
+ else if ((block = (char *)apr_hash_get (headers,
+ SVN_REPOS_DUMPFILE_UUID,
+ APR_HASH_KEY_STRING)) != NULL)
+ {
+ return svn_error_createf (SVN_ERR_STREAM_MALFORMED_DATA, NULL,
+ _("Found malformed UUID header block "
+ "near the line starting with a key %s %s "
+ "in dumpfile stream"), key, reason);
+ }
+ else if ((block = (char *)apr_hash_get (headers,
+ SVN_REPOS_DUMPFILE_MAGIC_HEADER,
+ APR_HASH_KEY_STRING)) != NULL)
+ {
+ return svn_error_createf (SVN_ERR_STREAM_MALFORMED_DATA, NULL,
+ _("Found malformed magic header block "
+ "near the line starting with a key %s %s "
+ "in dumpfile stream"), key, reason);
+ }
+ else
+ {
+ return svn_error_createf (SVN_ERR_STREAM_MALFORMED_DATA, NULL,
+ _("Found malformed unknown header block "
+ "near the line starting with a key %s %s "
+ "in dumpfile stream"), key, reason);
+ }
+}
+
 /*----------------------------------------------------------------------*/
 
 /** The parser and related helper funcs **/
@@ -153,9 +203,8 @@
       while (header_str->data[i] != ':')
         {
           if (header_str->data[i] == '\0')
- return svn_error_create (SVN_ERR_STREAM_MALFORMED_DATA, NULL,
- _("Found malformed header block "
- "in dumpfile stream"));
+ return contextual_error (*headers, header_str->data,
+ "with no : character");
           i++;
         }
       /* Create a 'name' string and point to it. */
@@ -165,9 +214,8 @@
       /* Skip over the NULL byte and the space following it. */
       i += 2;
       if (i > header_str->len)
- return svn_error_create (SVN_ERR_STREAM_MALFORMED_DATA, NULL,
- _("Found malformed header block "
- "in dumpfile stream"));
+ return contextual_error (*headers, header_str->data,
+ "with no value after a : character");
 
       /* Point to the 'value' string. */
       value = header_str->data + i;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jan 6 10:40:18 2006

This is an archived mail posted to the Subversion Dev mailing list.