diff --git a/extracters/ods2/ODS2-Image.exe b/extracters/ods2/ODS2-Image.exe index 86a75a7..cfe9404 100644 Binary files a/extracters/ods2/ODS2-Image.exe and b/extracters/ods2/ODS2-Image.exe differ diff --git a/extracters/ods2/ODS2.exe b/extracters/ods2/ODS2.exe index 09d0881..395cced 100644 Binary files a/extracters/ods2/ODS2.exe and b/extracters/ods2/ODS2.exe differ diff --git a/extracters/ods2/access.c b/extracters/ods2/access.c index 3e35a16..4083b4a 100644 --- a/extracters/ods2/access.c +++ b/extracters/ods2/access.c @@ -517,7 +517,7 @@ unsigned accesschunk(struct FCB *fcb,unsigned vbn,struct VIOC **retvioc, register unsigned int blocks; register struct VIOC *vioc; #ifdef DEBUG - printf("Access chunk %8x %d (%x)\n",base,vbn,fcb->cache.hashval); + printf("Access chunk %d (%x)\n",vbn,fcb->cache.hashval); #endif if (vbn < 1 || vbn > fcb->hiblock) return SS$_ENDOFFILE; blocks = (vbn - 1) / VIOC_CHUNKSIZE * VIOC_CHUNKSIZE; @@ -721,10 +721,6 @@ unsigned dismount(struct VCB * vcb) if (sts & 1) { cache_remove(&vcb->fcb->cache); while (vcb->dircache) cache_delete((struct CACHE *) vcb->dircache); -#ifdef DEBUG - printf("Post close\n"); - cachedump(); -#endif free(vcb); } } diff --git a/extracters/ods2/diskio.c b/extracters/ods2/diskio.c index 905b22a..0c56fa8 100644 --- a/extracters/ods2/diskio.c +++ b/extracters/ods2/diskio.c @@ -82,11 +82,12 @@ char *diskio_mapfile( const char *filename, int options ) { for( l = 0; l < 26; l++ ) { if( diskfiles[l] == NULL && L < 0) { #ifdef _WIN32 + char *pname; char dl[3] = { 'A', ':', '\0' }; dl[0] += l; if( ff < 0 ) ff = l; - if( driveFromLetter( dl ) == NULL) { + if( (pname = driveFromLetter( dl )) == NULL) { if( dl[0] >= 'C' ) { if( L < 0 ) L = l; @@ -94,7 +95,8 @@ char *diskio_mapfile( const char *filename, int options ) { if( ffa < 0 ) ffa = l; } - } + } else + free( pname ); #else L = l; #endif @@ -122,7 +124,11 @@ char *diskio_mapfile( const char *filename, int options ) { drives[L][3] = options; free(diskfiles[L]); diskfiles[L] = (char *) malloc( (l = strlen(filename) + 1) ); - snprintf( diskfiles[L], l, "%s", filename ); + if( diskfiles[L] == NULL ) { + perror( "malloc" ); + return NULL; + } + memcpy( diskfiles[L], filename, l ); printf( "%s assigned to %s\n", drives[L], diskfiles[L] ); @@ -160,6 +166,8 @@ int diskio_showdrives( void ) { } int diskio_unmapdrive( const char *drive ) { + if( drive[0] < 'A' || drive[0] > 'Z' ) + abort(); if( diskfiles[drive[0]-'A'] == NULL ) { return 0; } diff --git a/extracters/ods2/ods2.c b/extracters/ods2/ods2.c index cbbc967..9a8e52a 100644 --- a/extracters/ods2/ods2.c +++ b/extracters/ods2/ods2.c @@ -1573,42 +1573,71 @@ struct param moupars[] = { {"volumes", REQ, LIST, NOPA, { NULL, 0, 0, NOPA, NULL } }; +static int parselist( char ***items, size_t min, char *arg, const char *label ) { + size_t n = 0, i; + char **list = NULL; + + *items = NULL; + + while( *arg != '\0' ) { + char **nl; + + while( *arg == ' ' || *arg == '\t' ) + arg++; + if( *arg == '\0' ) + break; + + nl = (char **) realloc( list, (n < min? min +1: n +2) * sizeof( char * ) ); + if( nl == NULL ) { + free( list ); + printf( "%%ODS2-E-NOMEM, Not enough memory for %s\n", label ); + return -1; + } + list = nl; + + list[n++] = arg; + while( !(*arg == ',' || *arg == '\0') ) + arg++; + if( *arg == '\0' ) + break; + *arg++ = '\0'; + } + + if( list == NULL ) { + list = (char **) malloc( min + 1 ); + if( list == NULL ) { + printf( "%%ODS2-E-NOMEM, Not enough memory for %s\n", label ); + return -1; + } + } + for( i = n; i < min; i++ ) + list[i] = NULL; + + list[i] = NULL; + + *items = list; + return (int)n; +} unsigned domount(int argc,char *argv[],int qualc,char *qualv[]) { - char *dev = argv[1]; - char *lab = argv[2]; int sts = 1,devices = 0; - char *devs[100],*labs[100]; + char **devs = NULL, **labs = NULL; + int options; - options = checkquals(0,mouquals,qualc,qualv); + options = checkquals( 0, mouquals, qualc, qualv ); if( options == -1 ) return SS$_BADPARAM; UNUSED(argc); - memset( labs, 0, sizeof(labs) ); - memset( devs, 0, sizeof(devs) ); + if( (devices = parselist( &devs, 0, argv[1], "devices")) < 0 ) + return SS$_BADPARAM; + if( parselist( &labs, devices, argv[2], "labels") < 0 ) { + free( devs ); + return SS$_BADPARAM; + } - while (*lab != '\0') { - labs[devices++] = lab; - while (*lab != ',' && *lab != '\0') lab++; - if (*lab != '\0') { - *lab++ = '\0'; - } else { - break; - } - } - devices = 0; - while (*dev != '\0') { - devs[devices++] = dev; - while (*dev != ',' && *dev != '\0') dev++; - if (*dev != '\0') { - *dev++ = '\0'; - } else { - break; - } - } if (devices > 0) { struct VCB *vcb; #ifdef DISKIMAGE @@ -1617,8 +1646,11 @@ unsigned domount(int argc,char *argv[],int qualc,char *qualv[]) for( i = 0; i < (unsigned)devices; i++ ) { char *drive; drive = diskio_mapfile( devs[i], (options & mnt_write) != 0 ); - if( drive == NULL ) - return 0; + if( drive == NULL ) { + free( devs ); + free( labs ); + return SS$_DEVNOTMOUNT; + } devs[i] = drive; } #endif @@ -1651,6 +1683,9 @@ unsigned domount(int argc,char *argv[],int qualc,char *qualv[]) #endif } } + + free( devs ); + free( labs ); return sts; } diff --git a/extracters/ods2/phynt.c b/extracters/ods2/phynt.c index 3d00763..556d679 100644 --- a/extracters/ods2/phynt.c +++ b/extracters/ods2/phynt.c @@ -685,7 +685,7 @@ unsigned phyio_write(unsigned chan,unsigned block,unsigned length,char *buffer) if (transfer != sectblks * 512) { if (((sts = phy_getsect(chan,sectno)) & 1) == 0) break; } - memcpy(buffer,sectbuff + (offset * 512),transfer); + memcpy(sectbuff + (offset * 512),buffer,transfer); if (((sts = phy_putsect(chan,sectno)) & 1) == 0) break; buffer += transfer; length -= transfer; diff --git a/extracters/ods2/phyunix.c b/extracters/ods2/phyunix.c index b226f1b..f891b4b 100644 --- a/extracters/ods2/phyunix.c +++ b/extracters/ods2/phyunix.c @@ -95,7 +95,7 @@ unsigned phyio_read(unsigned handle,unsigned block,unsigned length,char *buffer) { off_t res; #ifdef DEBUG - printf("Phyio read block: %d into %x (%d bytes)\n",block,buffer,length); + printf("Phyio read block: %d into %p (%d bytes)\n",block,buffer,length); #endif read_count++; if ((res = lseek(handle,block*512,0)) < 0) { @@ -115,7 +115,7 @@ unsigned phyio_read(unsigned handle,unsigned block,unsigned length,char *buffer) unsigned phyio_write(unsigned handle,unsigned block,unsigned length,char *buffer) { #ifdef DEBUG - printf("Phyio write block: %d from %x (%d bytes)\n",block,buffer,length); + printf("Phyio write block: %d from %p (%d bytes)\n",block,buffer,length); #endif write_count++; if (lseek(handle,block*512,0) < 0) return SS$_PARITY;