diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2010-12-28 04:30:54 -0600 |
---|---|---|
committer | Jonathan Nieder <jrnieder@gmail.com> | 2011-03-22 16:41:09 -0500 |
commit | c9d1c8ba059577e64fb2213cb0c5f3c4619c7519 (patch) | |
tree | 1a5fcfb13c6065ba85cd8afe8ec6e8f4dfd11e1e /vcs-svn/fast_export.c | |
parent | 26557fc1b37480d184a32de025b060aa1aa231db (diff) | |
download | git-c9d1c8ba059577e64fb2213cb0c5f3c4619c7519.tar.gz |
vcs-svn: improve reporting of input errors
Catch input errors and exit early enough to print a reasonable
diagnosis based on errno.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Diffstat (limited to 'vcs-svn/fast_export.c')
-rw-r--r-- | vcs-svn/fast_export.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c index 260cf50e77..07a8353c8b 100644 --- a/vcs-svn/fast_export.c +++ b/vcs-svn/fast_export.c @@ -63,14 +63,23 @@ void fast_export_commit(uint32_t revision, uint32_t author, char *log, printf("progress Imported commit %"PRIu32".\n\n", revision); } +static void die_short_read(struct line_buffer *input) +{ + if (buffer_ferror(input)) + die_errno("error reading dump file"); + die("invalid dump: unexpected end of file"); +} + void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len, struct line_buffer *input) { if (mode == REPO_MODE_LNK) { /* svn symlink blobs start with "link " */ - buffer_skip_bytes(input, 5); len -= 5; + if (buffer_skip_bytes(input, 5) != 5) + die_short_read(input); } printf("blob\nmark :%"PRIu32"\ndata %"PRIu32"\n", mark, len); - buffer_copy_bytes(input, len); + if (buffer_copy_bytes(input, len) != len) + die_short_read(input); fputc('\n', stdout); } |