1
0
mirror of https://github.com/brouhaha/tapeutils.git synced 2026-01-11 23:53:18 +00:00

Read saveset name from the right place

Support DUMPER format 6, which has saveset name at different offset. Also check dumper tape format and reject too old or invalid format codes.
This commit is contained in:
Björn Victor 2025-01-22 17:31:32 +01:00 committed by GitHub
parent cc215f2212
commit 84a3a78d2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View File

@ -80,9 +80,13 @@ char *rectypes[] = {
#define BtoffWord 0 #define BtoffWord 0
#define BtlenWord 36 #define BtlenWord 36
#define WdoffSSstart 6 /* Start of saveset data */
#define WdoffSSFmt 6 /* Format of tape */
#define WdoffSSPtr 7 /* Pointer to saveset name (or 3 or 020 depending on format) */
#define WdoffSSDate 8 /* Saveset date offset (type 1, 6) */ #define WdoffSSDate 8 /* Saveset date offset (type 1, 6) */
#define WdoffSSName 9 /* Saveset name offset (type 1, 6) */ #define WdoffSSName 9 /* Saveset name offset (type 1, 6) */
#define WdoffFLName 6 /* Filename offset (type 2) */ #define WdoffFLName 6 /* Filename offset (type 2) */
#define WdoffSSMsg (020+WdoffSSstart) /* Saveset name (unless SSPtr set) */
#define WdoffFDB 134 /* FDB offset (type 2) */ #define WdoffFDB 134 /* FDB offset (type 2) */
#define WdoffFDB_CTL 01+WdoffFDB /* Control word .FBCTL */ #define WdoffFDB_CTL 01+WdoffFDB /* Control word .FBCTL */

View File

@ -519,13 +519,32 @@ void doSaveset (char *block, int contflag)
{ {
static char name[102]; static char name[102];
static char ss[2]; static char ss[2];
long ssfmt, ssptr;
long t; long t;
if (debug > 10) printf("\nSaveset header:"); if (debug > 10) printf("\nSaveset header:");
tapeno = getfield(block, WdoffTapeNum, BtoffTapeNum, BtlenTapeNum); tapeno = getfield(block, WdoffTapeNum, BtoffTapeNum, BtlenTapeNum);
ssno = getfield(block, WdoffSaveSetNum, BtoffSaveSetNum, ssno = getfield(block, WdoffSaveSetNum, BtoffSaveSetNum,
BtlenSaveSetNum); BtlenSaveSetNum);
getstring(block, name, WdoffSSName, sizeof(name)); ssfmt = getfield(block, WdoffSSFmt, BtoffWord, BtlenWord); /* Get format */
ssptr = getfield(block, WdoffSSPtr, BtoffWord, BtlenWord); /* Get pointer */
// Check tape format! Otherwise breaks e.g. on Install tapes (which aren't in dumper format).
if ((ssfmt < 4) || (ssfmt > 6)) {
// Formats older than 4 not supported, and 6 was the highest (TOPS-20 v6-7).
// If you want to support older fmts, write the code. :-)
fprintf (stderr, "Bad dumper tape format %012lo\n", ssfmt);
exit(1);
}
if (verbose) {
printf("Saveset format %ld, name pointer %ld; tape %ld, saveset %ld\n", ssfmt, ssptr, tapeno, ssno);
}
if (ssptr == 0) {
/* If there is no pointer, use default offset: for format 5-6 (T20 v6-7), SS.MSG, otherwise (T20 v4-5) BFMSG */
getstring(block, name, ssfmt > 4 ? WdoffSSMsg : WdoffSSName, sizeof(name));
} else {
getstring(block, name, ssptr+WdoffSSstart, sizeof(name));
}
ss[0] = pendstring(); /* superfluous */ ss[0] = pendstring(); /* superfluous */
(void) strcat(name, ss); (void) strcat(name, ss);