Module Name: src
Committed By: bouyer
Date: Thu Sep 3 19:31:34 UTC 2020
Modified Files:
src/sbin/restore: tape.c
Log Message:
If we hit an unknown header type (likely to be a corrupt record), and
the user choose to not abort, skip to the next header instead of trying
to use it.
This allowed me to recover files from a corrupt dump, instead of
getting a segfault.
To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sbin/restore/tape.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/restore/tape.c
diff -u src/sbin/restore/tape.c:1.68 src/sbin/restore/tape.c:1.69
--- src/sbin/restore/tape.c:1.68 Mon Mar 2 03:17:24 2015
+++ src/sbin/restore/tape.c Thu Sep 3 19:31:34 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tape.c,v 1.68 2015/03/02 03:17:24 enami Exp $ */
+/* $NetBSD: tape.c,v 1.69 2020/09/03 19:31:34 bouyer Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)tape.c 8.9 (Berkeley) 5/1/95";
#else
-__RCSID("$NetBSD: tape.c,v 1.68 2015/03/02 03:17:24 enami Exp $");
+__RCSID("$NetBSD: tape.c,v 1.69 2020/09/03 19:31:34 bouyer Exp $");
#endif
#endif /* not lint */
@@ -1384,6 +1384,7 @@ findinode(struct s_spcl *header)
top:
do {
if (header->c_magic != FS_UFS2_MAGIC) {
+skip:
skipcnt++;
while (gethead(header) == FAIL ||
header->c_date != dumpdate)
@@ -1438,7 +1439,8 @@ findinode(struct s_spcl *header)
default:
panic("unknown tape header type %d\n", spcl.c_type);
- break;
+ fprintf(stderr, "skiping to next header\n");
+ goto skip;
}
} while (header->c_type == TS_ADDR);