From 5c28a8b054cb69a37638b0261fc370422c8fab58 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Fri, 19 Nov 2010 18:46:06 -0600 Subject: [PATCH] vcs-svn: Check for errors from open() test-svn-fe segfaults when passed a bogus path. Simplify debugging by exiting with a meaningful error message instead. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- contrib/svn-fe/svn-fe.c | 3 ++- test-svn-fe.c | 3 ++- vcs-svn/svndump.c | 6 ++++-- vcs-svn/svndump.h | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/contrib/svn-fe/svn-fe.c b/contrib/svn-fe/svn-fe.c index a2677b03e..35db24f5e 100644 --- a/contrib/svn-fe/svn-fe.c +++ b/contrib/svn-fe/svn-fe.c @@ -8,7 +8,8 @@ int main(int argc, char **argv) { - svndump_init(NULL); + if (svndump_init(NULL)) + return 1; svndump_read((argc > 1) ? argv[1] : NULL); svndump_deinit(); svndump_reset(); diff --git a/test-svn-fe.c b/test-svn-fe.c index 77cf78abc..b42ba789b 100644 --- a/test-svn-fe.c +++ b/test-svn-fe.c @@ -9,7 +9,8 @@ int main(int argc, char *argv[]) { if (argc != 2) usage("test-svn-fe "); - svndump_init(argv[1]); + if (svndump_init(argv[1])) + return 1; svndump_read(NULL); svndump_deinit(); svndump_reset(); diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c index 6b64c1b85..db1185122 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -290,14 +290,16 @@ void svndump_read(const char *url) handle_revision(); } -void svndump_init(const char *filename) +int svndump_init(const char *filename) { - buffer_init(filename); + if (buffer_init(filename)) + return error("cannot open %s: %s", filename, strerror(errno)); repo_init(); reset_dump_ctx(~0); reset_rev_ctx(0); reset_node_ctx(NULL); init_keys(); + return 0; } void svndump_deinit(void) diff --git a/vcs-svn/svndump.h b/vcs-svn/svndump.h index 93c412f14..df9ceb0e8 100644 --- a/vcs-svn/svndump.h +++ b/vcs-svn/svndump.h @@ -1,7 +1,7 @@ #ifndef SVNDUMP_H_ #define SVNDUMP_H_ -void svndump_init(const char *filename); +int svndump_init(const char *filename); void svndump_read(const char *url); void svndump_deinit(void); void svndump_reset(void); -- 2.26.2