From e34003c579723f2e6e184b9a4a74965320b8eaf4 Mon Sep 17 00:00:00 2001
From: Brian Carrier <carrier@sleuthkit.org>
Date: Wed, 28 Oct 2009 21:00:28 +0000
Subject: [PATCH] Changed command line tools to specify offsets using -b for
 sector size instead of the 63@4096 format

---
 CHANGES.txt               |  8 +++--
 man/blkcalc.1             |  3 +-
 man/blkcat.1              |  3 +-
 man/blkls.1               |  3 +-
 man/blkstat.1             |  3 +-
 man/ffind.1               |  3 +-
 man/fls.1                 |  3 +-
 man/fsstat.1              |  3 +-
 man/icat.1                |  3 +-
 man/ifind.1               |  3 +-
 man/ils.1                 |  3 +-
 man/istat.1               |  3 +-
 man/jcat.1                |  3 +-
 man/jls.1                 |  3 +-
 tools/fstools/blkcalc.cpp |  8 ++---
 tools/fstools/blkcat.cpp  | 12 ++++----
 tools/fstools/blkls.cpp   | 18 ++++++------
 tools/fstools/blkstat.cpp |  8 ++---
 tools/fstools/ffind.cpp   |  8 ++---
 tools/fstools/fls.cpp     | 12 ++++----
 tools/fstools/fscheck.cpp |  4 +--
 tools/fstools/fsstat.cpp  |  8 ++---
 tools/fstools/icat.cpp    |  8 ++---
 tools/fstools/ifind.cpp   |  8 ++---
 tools/fstools/ils.cpp     | 16 +++++-----
 tools/fstools/istat.cpp   |  8 ++---
 tools/fstools/jcat.cpp    | 10 +++----
 tools/fstools/jls.cpp     | 10 +++----
 tools/vstools/mmcat.cpp   |  8 ++---
 tools/vstools/mmls.cpp    |  8 ++---
 tools/vstools/mmstat.cpp  |  8 ++---
 tsk3/base/tsk_parse.c     | 61 +++++++++++----------------------------
 tsk3/img/img_open.c       |  8 +++++
 33 files changed, 125 insertions(+), 153 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 6b5d6fdf1..dbcbe522f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -103,9 +103,13 @@ in extended partitions were not marked as Meta.
 
 10/27/09: Update: 'mmls -b' is now 'mmls -B'.  Similarly with istat -b.
 
-10/27/09: Update: Added sector_size value to IMG_INFO and file and volume
+10/27/09: Update/Fix: Added sector_size value to IMG_INFO and file and volume
 systems now use it instead of assuming 512. Also added -b options to all
-command line tools to allow user to specify the device sector size. 
+command line tools to allow user to specify the device sector size.  This
+solves bug 2874854. 
+
+10/28/09: Update: Changed command line format for '-o' so that sector size
+is specified only via -b and not using '-o 62@4096'.
 
 ---------------- VERSION 3.0.1 -------------- 
 11/11/08: Bug Fix: Fixed crashing bug in ifind on FAT file system.
diff --git a/man/blkcalc.1 b/man/blkcalc.1
index 6281ea4d2..45fd9010f 100644
--- a/man/blkcalc.1
+++ b/man/blkcalc.1
@@ -51,8 +51,7 @@ If not given, autodetection methods are used.
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. 
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048)
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. 
 .IP -v
diff --git a/man/blkcat.1 b/man/blkcat.1
index 969a6fb47..c820c15e1 100644
--- a/man/blkcat.1
+++ b/man/blkcat.1
@@ -40,8 +40,7 @@ images.
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. 
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -v
diff --git a/man/blkls.1 b/man/blkls.1
index 25487e74b..655405428 100644
--- a/man/blkls.1
+++ b/man/blkls.1
@@ -43,8 +43,7 @@ If not given, autodetection methods are used.
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. 
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -l
diff --git a/man/blkstat.1 b/man/blkstat.1
index dcf675730..d9407f37d 100644
--- a/man/blkstat.1
+++ b/man/blkstat.1
@@ -22,8 +22,7 @@ If not given, autodetection methods are used.
 Identify the type of image file, such as raw or split. Use '-i list' to list the supported types.  
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -v
diff --git a/man/ffind.1 b/man/ffind.1
index 02950bba0..09882f8ac 100644
--- a/man/ffind.1
+++ b/man/ffind.1
@@ -34,8 +34,7 @@ Find undeleted entries only.
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. 
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -v
diff --git a/man/fls.1 b/man/fls.1
index 4b7db7c45..31d6eb7b8 100644
--- a/man/fls.1
+++ b/man/fls.1
@@ -66,8 +66,7 @@ is only used if -l or -m are given.
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. 
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -u  
diff --git a/man/fsstat.1 b/man/fsstat.1
index 67518bfd7..40108159a 100644
--- a/man/fsstat.1
+++ b/man/fsstat.1
@@ -29,8 +29,7 @@ If not given, autodetection methods are used.
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. 
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -v
diff --git a/man/icat.1 b/man/icat.1
index 8321e7291..d14b9252d 100644
--- a/man/icat.1
+++ b/man/icat.1
@@ -34,8 +34,7 @@ Include the slack space in the output.
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. 
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -v
diff --git a/man/ifind.1 b/man/ifind.1
index 01dc7a323..d80f98edf 100644
--- a/man/ifind.1
+++ b/man/ifind.1
@@ -45,8 +45,7 @@ List the details of each file found with '-p', like 'fls -l'.
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. 
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -v
diff --git a/man/ils.1 b/man/ils.1
index f193fbe4f..a45bc2241 100644
--- a/man/ils.1
+++ b/man/ils.1
@@ -58,8 +58,7 @@ for \fB-LZ\fR
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. 
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP \fB-v\fR
diff --git a/man/istat.1 b/man/istat.1
index 55654f78e..8f95c1e9b 100644
--- a/man/istat.1
+++ b/man/istat.1
@@ -32,8 +32,7 @@ original system was 100 seconds slow, this value would be -100.
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. 
 If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -v
diff --git a/man/jcat.1 b/man/jcat.1
index 40eba3a1a..c84381873 100644
--- a/man/jcat.1
+++ b/man/jcat.1
@@ -24,8 +24,7 @@ Specify the file system type.  Use '-f list' to list the supported file system t
 .IP "-i imgtype"
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -V
diff --git a/man/jls.1 b/man/jls.1
index b56c940df..00747ed99 100644
--- a/man/jls.1
+++ b/man/jls.1
@@ -21,8 +21,7 @@ Use '-f list' to list the supported file system types. If not given, autodetecti
 .IP "-i imgtype"
 Identify the type of image file, such as raw or split.  Use '-i list' to list the supported types. If not given, autodetection methods are used.
 .IP "-o imgoffset"
-The sector offset where the file system starts in the image.  Non-512 byte
-sectors can be specified using '@' (32@2048).
+The sector offset where the file system starts in the image.  
 .IP "-b dev_sector_size"
 The size, in bytes, of the underlying device sectors.  If not given, the value in the image format is used (if it exists) or 512-bytes is assumed.
 .IP -V
diff --git a/tools/fstools/blkcalc.cpp b/tools/fstools/blkcalc.cpp
index e5d6df939..ea82cc529 100644
--- a/tools/fstools/blkcalc.cpp
+++ b/tools/fstools/blkcalc.cpp
@@ -63,7 +63,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -147,7 +147,7 @@ main(int argc, char **argv1)
             break;
 
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -207,14 +207,14 @@ main(int argc, char **argv1)
         tsk_error_print(stderr);
         exit(1);
     }
-    if (imgoff >= img->size) {
+    if ((imgaddr * img->sector_size) >= img->size) {
         tsk_fprintf(stderr,
             "Sector offset supplied is larger than disk image (maximum: %"
             PRIu64 ")\n", img->size / 512);
         exit(1);
     }
 
-    if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+    if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
             tsk_fs_type_print(stderr);
diff --git a/tools/fstools/blkcat.cpp b/tools/fstools/blkcat.cpp
index b765c2de4..f2d20ecec 100644
--- a/tools/fstools/blkcat.cpp
+++ b/tools/fstools/blkcat.cpp
@@ -64,7 +64,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -143,7 +143,7 @@ main(int argc, char **argv1)
             }
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -213,7 +213,7 @@ main(int argc, char **argv1)
             tsk_error_print(stderr);
             exit(1);
         }
-        if (imgoff >= img->size) {
+        if ((imgaddr * img->sector_size) >= img->size) {
             tsk_fprintf(stderr,
                 "Sector offset supplied is larger than disk image (maximum: %"
                 PRIu64 ")\n", img->size / 512);
@@ -239,7 +239,7 @@ main(int argc, char **argv1)
                 tsk_error_print(stderr);
                 exit(1);
             }
-            if (imgoff >= img->size) {
+            if ((imgaddr * img->sector_size) >= img->size) {
                 tsk_fprintf(stderr,
                     "Sector offset supplied is larger than disk image (maximum: %"
                     PRIu64 ")\n", img->size / 512);
@@ -268,7 +268,7 @@ main(int argc, char **argv1)
                 tsk_error_print(stderr);
                 exit(1);
             }
-            if (imgoff >= img->size) {
+            if ((imgaddr * img->sector_size) >= img->size) {
                 tsk_fprintf(stderr,
                     "Sector offset supplied is larger than disk image (maximum: %"
                     PRIu64 ")\n", img->size / 512);
@@ -278,7 +278,7 @@ main(int argc, char **argv1)
     }
 
     /* open the file */
-    if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+    if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
             tsk_fs_type_print(stderr);
diff --git a/tools/fstools/blkls.cpp b/tools/fstools/blkls.cpp
index a4f5d0b90..081abdf6c 100644
--- a/tools/fstools/blkls.cpp
+++ b/tools/fstools/blkls.cpp
@@ -71,7 +71,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -154,7 +154,7 @@ main(int argc, char **argv1)
             lclflags = TSK_FS_BLKLS_LIST;
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -193,14 +193,14 @@ main(int argc, char **argv1)
             tsk_error_print(stderr);
             exit(1);
         }
-        if (imgoff >= img->size) {
+        if ((imgaddr * img->sector_size) >= img->size) {
             tsk_fprintf(stderr,
                 "Sector offset supplied is larger than disk image (maximum: %"
                 PRIu64 ")\n", img->size / 512);
             exit(1);
         }
 
-        if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+        if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
             tsk_error_print(stderr);
             if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
                 tsk_fs_type_print(stderr);
@@ -219,7 +219,7 @@ main(int argc, char **argv1)
                 tsk_error_print(stderr);
                 exit(1);
             }
-            if (imgoff >= img->size) {
+            if ((imgaddr * img->sector_size) >= img->size) {
                 tsk_fprintf(stderr,
                     "Sector offset supplied is larger than disk image (maximum: %"
                     PRIu64 ")\n", img->size / 512);
@@ -242,7 +242,7 @@ main(int argc, char **argv1)
                     tsk_error_print(stderr);
                     exit(1);
                 }
-                if (imgoff >= img->size) {
+                if ((imgaddr * img->sector_size) >= img->size) {
                     tsk_fprintf(stderr,
                         "Sector offset supplied is larger than disk image (maximum: %"
                         PRIu64 ")\n", img->size / 512);
@@ -265,7 +265,7 @@ main(int argc, char **argv1)
                         tsk_error_print(stderr);
                         exit(1);
                     }
-                    if (imgoff >= img->size) {
+                    if ((imgaddr * img->sector_size) >= img->size) {
                         tsk_fprintf(stderr,
                             "Sector offset supplied is larger than disk image (maximum: %"
                             PRIu64 ")\n", img->size / 512);
@@ -284,7 +284,7 @@ main(int argc, char **argv1)
                         tsk_error_print(stderr);
                         exit(1);
                     }
-                    if (imgoff >= img->size) {
+                    if ((imgaddr * img->sector_size) >= img->size) {
                         tsk_fprintf(stderr,
                             "Sector offset supplied is larger than disk image (maximum: %"
                             PRIu64 ")\n", img->size / 512);
@@ -294,7 +294,7 @@ main(int argc, char **argv1)
             }
         }
 
-        if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+        if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
             tsk_error_print(stderr);
             if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
                 tsk_fs_type_print(stderr);
diff --git a/tools/fstools/blkstat.cpp b/tools/fstools/blkstat.cpp
index 4aef47dc7..7b8418d80 100644
--- a/tools/fstools/blkstat.cpp
+++ b/tools/fstools/blkstat.cpp
@@ -48,7 +48,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -113,7 +113,7 @@ main(int argc, char **argv1)
             }
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -151,13 +151,13 @@ main(int argc, char **argv1)
         tsk_error_print(stderr);
         exit(1);
     }
-    if (imgoff >= img->size) {
+    if ((imgaddr * img->sector_size) >= img->size) {
         tsk_fprintf(stderr,
             "Sector offset supplied is larger than disk image (maximum: %"
             PRIu64 ")\n", img->size / 512);
         exit(1);
     }
-    if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+    if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
             tsk_fs_type_print(stderr);
diff --git a/tools/fstools/ffind.cpp b/tools/fstools/ffind.cpp
index e2fddacb3..8dc67106c 100644
--- a/tools/fstools/ffind.cpp
+++ b/tools/fstools/ffind.cpp
@@ -54,7 +54,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -127,7 +127,7 @@ main(int argc, char **argv1)
             }
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -178,13 +178,13 @@ main(int argc, char **argv1)
         tsk_error_print(stderr);
         exit(1);
     }
-    if (imgoff >= img->size) {
+    if ((imgaddr * img->sector_size) >= img->size) {
         tsk_fprintf(stderr,
             "Sector offset supplied is larger than disk image (maximum: %"
             PRIu64 ")\n", img->size / 512);
         exit(1);
     }
-    if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+    if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
             tsk_fs_type_print(stderr);
diff --git a/tools/fstools/fls.cpp b/tools/fstools/fls.cpp
index f5251ae30..e47f4f8dc 100644
--- a/tools/fstools/fls.cpp
+++ b/tools/fstools/fls.cpp
@@ -70,7 +70,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -165,7 +165,7 @@ main(int argc, char **argv1)
             macpre = OPTARG;
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -254,13 +254,13 @@ main(int argc, char **argv1)
             tsk_error_print(stderr);
             exit(1);
         }
-        if (imgoff >= img->size) {
+        if ((imgaddr * img->sector_size) >= img->size) {
             tsk_fprintf(stderr,
                 "Sector offset supplied is larger than disk image (maximum: %"
                 PRIu64 ")\n", img->size / 512);
             exit(1);
         }
-        if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+        if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
             tsk_error_print(stderr);
             if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
                 tsk_fs_type_print(stderr);
@@ -283,7 +283,7 @@ main(int argc, char **argv1)
             tsk_error_print(stderr);
             exit(1);
         }
-        if (imgoff >= img->size) {
+        if ((imgaddr * img->sector_size) >= img->size) {
             tsk_fprintf(stderr,
                 "Sector offset supplied is larger than disk image (maximum: %"
                 PRIu64 ")\n", img->size / 512);
@@ -291,7 +291,7 @@ main(int argc, char **argv1)
         }
 
 
-        if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+        if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
             tsk_error_print(stderr);
             if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
                 tsk_fs_type_print(stderr);
diff --git a/tools/fstools/fscheck.cpp b/tools/fstools/fscheck.cpp
index 863074ce0..b528fc997 100644
--- a/tools/fstools/fscheck.cpp
+++ b/tools/fstools/fscheck.cpp
@@ -36,7 +36,7 @@ main(int argc, char **argv)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -102,7 +102,7 @@ main(int argc, char **argv)
             break;
 
         case 'o':
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
diff --git a/tools/fstools/fsstat.cpp b/tools/fstools/fsstat.cpp
index eaa2d46e0..f68594c1a 100644
--- a/tools/fstools/fsstat.cpp
+++ b/tools/fstools/fsstat.cpp
@@ -46,7 +46,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -114,7 +114,7 @@ main(int argc, char **argv1)
             break;
 
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -146,14 +146,14 @@ main(int argc, char **argv1)
         tsk_error_print(stderr);
         exit(1);
     }
-    if (imgoff >= img->size) {
+    if ((imgaddr * img->sector_size) >= img->size) {
         tsk_fprintf(stderr,
             "Sector offset supplied is larger than disk image (maximum: %"
             PRIu64 ")\n", img->size / 512);
         exit(1);
     }
 
-    if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+    if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
             tsk_fs_type_print(stderr);
diff --git a/tools/fstools/icat.cpp b/tools/fstools/icat.cpp
index c82d1199f..d15f956fa 100644
--- a/tools/fstools/icat.cpp
+++ b/tools/fstools/icat.cpp
@@ -60,7 +60,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -135,7 +135,7 @@ main(int argc, char **argv1)
             }
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -178,13 +178,13 @@ main(int argc, char **argv1)
         tsk_error_print(stderr);
         exit(1);
     }
-    if (imgoff >= img->size) {
+    if ((imgaddr * img->sector_size) >= img->size) {
         tsk_fprintf(stderr,
             "Sector offset supplied is larger than disk image (maximum: %"
             PRIu64 ")\n", img->size / 512);
         exit(1);
     }
-    if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+    if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
             tsk_fs_type_print(stderr);
diff --git a/tools/fstools/ifind.cpp b/tools/fstools/ifind.cpp
index 327550a4c..2d8c4ac08 100644
--- a/tools/fstools/ifind.cpp
+++ b/tools/fstools/ifind.cpp
@@ -67,7 +67,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
     uint8_t type = 0;
@@ -171,7 +171,7 @@ main(int argc, char **argv1)
                 break;
             }
         case 'o':
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -238,14 +238,14 @@ main(int argc, char **argv1)
             free(path);
         exit(1);
     }
-    if (imgoff >= img->size) {
+    if ((imgaddr * img->sector_size) >= img->size) {
         tsk_fprintf(stderr,
             "Sector offset supplied is larger than disk image (maximum: %"
             PRIu64 ")\n", img->size / 512);
         exit(1);
     }
 
-    if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+    if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
             tsk_fs_type_print(stderr);
diff --git a/tools/fstools/ils.cpp b/tools/fstools/ils.cpp
index 6fbefb0db..2e92a79fe 100644
--- a/tools/fstools/ils.cpp
+++ b/tools/fstools/ils.cpp
@@ -72,7 +72,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -155,7 +155,7 @@ main(int argc, char **argv1)
             ils_flags |= TSK_FS_ILS_MAC;
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -231,7 +231,7 @@ main(int argc, char **argv1)
                 tsk_error_print(stderr);
                 exit(1);
             }
-            if (imgoff >= img->size) {
+            if ((imgaddr * img->sector_size) >= img->size) {
                 tsk_fprintf(stderr,
                     "Sector offset supplied is larger than disk image (maximum: %"
                     PRIu64 ")\n", img->size / 512);
@@ -249,7 +249,7 @@ main(int argc, char **argv1)
                 tsk_error_print(stderr);
                 exit(1);
             }
-            if (imgoff >= img->size) {
+            if ((imgaddr * img->sector_size) >= img->size) {
                 tsk_fprintf(stderr,
                     "Sector offset supplied is larger than disk image (maximum: %"
                     PRIu64 ")\n", img->size / 512);
@@ -272,7 +272,7 @@ main(int argc, char **argv1)
                 tsk_error_print(stderr);
                 exit(1);
             }
-            if (imgoff >= img->size) {
+            if ((imgaddr * img->sector_size) >= img->size) {
                 tsk_fprintf(stderr,
                     "Sector offset supplied is larger than disk image (maximum: %"
                     PRIu64 ")\n", img->size / 512);
@@ -293,7 +293,7 @@ main(int argc, char **argv1)
                     tsk_error_print(stderr);
                     exit(1);
                 }
-                if (imgoff >= img->size) {
+                if ((imgaddr * img->sector_size) >= img->size) {
                     tsk_fprintf(stderr,
                         "Sector offset supplied is larger than disk image (maximum: %"
                         PRIu64 ")\n", img->size / 512);
@@ -310,7 +310,7 @@ main(int argc, char **argv1)
                     tsk_error_print(stderr);
                     exit(1);
                 }
-                if (imgoff >= img->size) {
+                if ((imgaddr * img->sector_size) >= img->size) {
                     tsk_fprintf(stderr,
                         "Sector offset supplied is larger than disk image (maximum: %"
                         PRIu64 ")\n", img->size / 512);
@@ -320,7 +320,7 @@ main(int argc, char **argv1)
         }
     }
 
-    if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+    if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
             tsk_fs_type_print(stderr);
diff --git a/tools/fstools/istat.cpp b/tools/fstools/istat.cpp
index afef35438..a0d8902f9 100644
--- a/tools/fstools/istat.cpp
+++ b/tools/fstools/istat.cpp
@@ -58,7 +58,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -138,7 +138,7 @@ main(int argc, char **argv1)
             }
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -192,14 +192,14 @@ main(int argc, char **argv1)
         tsk_error_print(stderr);
         exit(1);
     }
-    if (imgoff >= img->size) {
+    if ((imgaddr * img->sector_size) >= img->size) {
         tsk_fprintf(stderr,
             "Sector offset supplied is larger than disk image (maximum: %"
             PRIu64 ")\n", img->size / 512);
         exit(1);
     }
 
-    if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+    if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
             tsk_fs_type_print(stderr);
diff --git a/tools/fstools/jcat.cpp b/tools/fstools/jcat.cpp
index 017c6af90..486a3b123 100644
--- a/tools/fstools/jcat.cpp
+++ b/tools/fstools/jcat.cpp
@@ -49,7 +49,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -116,7 +116,7 @@ main(int argc, char **argv1)
             }
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -151,14 +151,14 @@ main(int argc, char **argv1)
             tsk_error_print(stderr);
             exit(1);
         }
-        if (imgoff >= img->size) {
+        if ((imgaddr * img->sector_size) >= img->size) {
             tsk_fprintf(stderr,
                 "Sector offset supplied is larger than disk image (maximum: %"
                 PRIu64 ")\n", img->size / 512);
             exit(1);
         }
 
-        if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+        if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
             tsk_error_print(stderr);
             if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
                 tsk_fs_type_print(stderr);
@@ -175,7 +175,7 @@ main(int argc, char **argv1)
             exit(1);
         }
 
-        if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+        if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
             tsk_error_print(stderr);
             if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
                 tsk_fs_type_print(stderr);
diff --git a/tools/fstools/jls.cpp b/tools/fstools/jls.cpp
index efd2bc8ec..7b53b67bd 100644
--- a/tools/fstools/jls.cpp
+++ b/tools/fstools/jls.cpp
@@ -42,7 +42,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_IMG_INFO *img;
 
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_FS_TYPE_ENUM fstype = TSK_FS_TYPE_DETECT;
     TSK_FS_INFO *fs;
 
@@ -108,7 +108,7 @@ main(int argc, char **argv1)
             }
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -141,14 +141,14 @@ main(int argc, char **argv1)
             tsk_error_print(stderr);
             exit(1);
         }
-        if (imgoff >= img->size) {
+        if ((imgaddr * img->sector_size) >= img->size) {
             tsk_fprintf(stderr,
                 "Sector offset supplied is larger than disk image (maximum: %"
                 PRIu64 ")\n", img->size / 512);
             exit(1);
         }
 
-        if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+        if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
             tsk_error_print(stderr);
             if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
                 tsk_fs_type_print(stderr);
@@ -166,7 +166,7 @@ main(int argc, char **argv1)
             exit(1);
         }
 
-        if ((fs = tsk_fs_open_img(img, imgoff, fstype)) == NULL) {
+        if ((fs = tsk_fs_open_img(img, imgaddr * img->sector_size, fstype)) == NULL) {
             tsk_error_print(stderr);
             if (tsk_errno == TSK_ERR_FS_UNSUPTYPE)
                 tsk_fs_type_print(stderr);
diff --git a/tools/vstools/mmcat.cpp b/tools/vstools/mmcat.cpp
index 7d9a300f4..8517093bb 100644
--- a/tools/vstools/mmcat.cpp
+++ b/tools/vstools/mmcat.cpp
@@ -41,7 +41,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_VS_TYPE_ENUM vstype = TSK_VS_TYPE_DETECT;
     int ch;
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_IMG_INFO *img;
     TSK_PNUM_T pnum;
     TSK_DADDR_T addr;
@@ -91,7 +91,7 @@ main(int argc, char **argv1)
             break;
 
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -136,7 +136,7 @@ main(int argc, char **argv1)
         tsk_error_print(stderr);
         exit(1);
     }
-    if (imgoff >= img->size) {
+    if ((imgaddr * img->sector_size) >= img->size) {
         tsk_fprintf(stderr,
             "Sector offset supplied is larger than disk image (maximum: %"
             PRIu64 ")\n", img->size / 512);
@@ -149,7 +149,7 @@ main(int argc, char **argv1)
     }
 
     /* process the partition tables */
-    if ((vs = tsk_vs_open(img, imgoff, vstype)) == NULL) {
+    if ((vs = tsk_vs_open(img, imgaddr * img->sector_size, vstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_VS_UNSUPTYPE)
             tsk_vs_type_print(stderr);
diff --git a/tools/vstools/mmls.cpp b/tools/vstools/mmls.cpp
index fb7621c7e..d9a974522 100644
--- a/tools/vstools/mmls.cpp
+++ b/tools/vstools/mmls.cpp
@@ -148,7 +148,7 @@ main(int argc, char **argv1)
 {
     TSK_VS_INFO *vs;
     int ch;
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     int flags = 0;
     TSK_IMG_INFO *img;
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
@@ -213,7 +213,7 @@ main(int argc, char **argv1)
             hide_meta = 1;
             break;
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -271,7 +271,7 @@ main(int argc, char **argv1)
         tsk_error_print(stderr);
         exit(1);
     }
-    if (imgoff >= img->size) {
+    if ((imgaddr * img->sector_size) >= img->size) {
         tsk_fprintf(stderr,
             "Sector offset supplied is larger than disk image (maximum: %"
             PRIu64 ")\n", img->size / 512);
@@ -279,7 +279,7 @@ main(int argc, char **argv1)
     }
 
     /* process the partition tables */
-    vs = tsk_vs_open(img, (TSK_OFF_T) imgoff, vstype);
+    vs = tsk_vs_open(img, imgaddr * img->sector_size, vstype);
     if (vs == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_VS_UNSUPTYPE)
diff --git a/tools/vstools/mmstat.cpp b/tools/vstools/mmstat.cpp
index 50ef70a46..c26e5e06d 100644
--- a/tools/vstools/mmstat.cpp
+++ b/tools/vstools/mmstat.cpp
@@ -48,7 +48,7 @@ main(int argc, char **argv1)
     TSK_IMG_TYPE_ENUM imgtype = TSK_IMG_TYPE_DETECT;
     TSK_VS_TYPE_ENUM vstype = TSK_VS_TYPE_DETECT;
     int ch;
-    TSK_OFF_T imgoff = 0;
+    TSK_OFF_T imgaddr = 0;
     TSK_IMG_INFO *img;
     TSK_TCHAR **argv;
     unsigned int ssize = 0;
@@ -93,7 +93,7 @@ main(int argc, char **argv1)
             break;
 
         case _TSK_T('o'):
-            if ((imgoff = tsk_parse_offset(OPTARG)) == -1) {
+            if ((imgaddr = tsk_parse_offset(OPTARG)) == -1) {
                 tsk_error_print(stderr);
                 exit(1);
             }
@@ -137,7 +137,7 @@ main(int argc, char **argv1)
         tsk_error_print(stderr);
         exit(1);
     }
-    if (imgoff >= img->size) {
+    if ((imgaddr * img->sector_size) >= img->size) {
         tsk_fprintf(stderr,
             "Sector offset supplied is larger than disk image (maximum: %"
             PRIu64 ")\n", img->size / 512);
@@ -146,7 +146,7 @@ main(int argc, char **argv1)
 
 
     /* process the partition tables */
-    if ((vs = tsk_vs_open(img, imgoff, vstype)) == NULL) {
+    if ((vs = tsk_vs_open(img, imgaddr * img->sector_size, vstype)) == NULL) {
         tsk_error_print(stderr);
         if (tsk_errno == TSK_ERR_VS_UNSUPTYPE)
             tsk_vs_type_print(stderr);
diff --git a/tsk3/base/tsk_parse.c b/tsk3/base/tsk_parse.c
index 545090a49..c77352dfd 100644
--- a/tsk3/base/tsk_parse.c
+++ b/tsk3/base/tsk_parse.c
@@ -17,22 +17,20 @@
 
 /**
  * \ingroup baselib
- * Parse a TSK_TCHAR block address string in the cnt\@size or 
- * cnt format.  If size is not given, 512 is used. 
- * Return the byte offset in an integer format. 
+ * Parse a TSK_TCHAR block address string. 
+ * Note that the cnt\@size format is no longer supported.
+ * Set the device sector size in img_open to set the block size. 
  *
  * @param [in] a_offset_str The string version of the offset
- * @return -1 on error or byte offset on success
+ * @return -1 on error or block offset on success
  */
 TSK_OFF_T
 tsk_parse_offset(const TSK_TCHAR * a_offset_str)
 {
     TSK_TCHAR offset_lcl[64], *offset_lcl_p;
     TSK_DADDR_T num_blk;
-    TSK_TCHAR *cp, *at;
-    int bsize;
-    TSK_OFF_T offset_b;
-
+    TSK_TCHAR *cp;
+    
     if (a_offset_str == NULL) {
         return 0;
     }
@@ -49,41 +47,23 @@ tsk_parse_offset(const TSK_TCHAR * a_offset_str)
     TSTRNCPY(offset_lcl, a_offset_str, 64);
     offset_lcl_p = offset_lcl;
 
-    /* Check for the x@y setup  and set
-     * bsize if it exists
-     */
-    if ((at = TSTRCHR(offset_lcl_p, '@')) != NULL) {
-        *at = '\0';
-        at++;
-
-        bsize = TSTRTOUL(at, &cp, 0);
-        if (*cp || *cp == *at) {
-            tsk_error_reset();
-            tsk_errno = TSK_ERR_IMG_OFFSET;
-            snprintf(tsk_errstr, TSK_ERRSTR_L,
-                "tsk_parse: block size: %" PRIttocTSK, at);
-            return -1;
-        }
-        else if (bsize % 512) {
-            tsk_error_reset();
-            tsk_errno = TSK_ERR_IMG_OFFSET;
-            snprintf(tsk_errstr, TSK_ERRSTR_L,
-                "tsk_parse: block size not multiple of 512");
-            return -1;
-        }
-    }
-    else {
-        bsize = 512;
+    /* Check for the old x@y setup */
+    if (TSTRCHR(offset_lcl_p, '@') != NULL) {
+        tsk_error_reset();
+        tsk_errno = TSK_ERR_IMG_OFFSET;
+        snprintf(tsk_errstr, TSK_ERRSTR_L,
+                 "tsk_parse: offset string format no longer supported.  Use -b to specify sector size: %" PRIttocTSK,
+                 a_offset_str);
+        return -1;
     }
 
-
-    /* Now we address the sector offset */
     offset_lcl_p = offset_lcl;
 
     /* remove leading 0s */
     while ((offset_lcl_p[0] != '\0') && (offset_lcl_p[0] == '0'))
         offset_lcl_p++;
 
+    num_blk = 0;
     if (offset_lcl_p[0] != '\0') {
         num_blk = TSTRTOULL(offset_lcl_p, &cp, 0);
         if (*cp || *cp == *offset_lcl_p) {
@@ -94,21 +74,14 @@ tsk_parse_offset(const TSK_TCHAR * a_offset_str)
                 offset_lcl_p);
             return -1;
         }
-        offset_b = num_blk * bsize;
-    }
-    else {
-        offset_b = 0;
     }
 
-    if (tsk_verbose)
-        tsk_fprintf(stderr,
-            "tsk_parse_offset: Offset set to %" PRIuOFF "\n", offset_b);
-
-    return offset_b;
+    return num_blk;
 }
 
 
 
+
 /**
  * \ingroup baselib
  * Parse a TSK_TCHAR string of a partition byte offset and the 
diff --git a/tsk3/img/img_open.c b/tsk3/img/img_open.c
index f3aca5541..7c223a0f9 100644
--- a/tsk3/img/img_open.c
+++ b/tsk3/img/img_open.c
@@ -93,6 +93,14 @@ tsk_img_open(int num_img,
         snprintf(tsk_errstr, TSK_ERRSTR_L, "sector size is less than 512 bytes (%d)", a_ssize);
         return NULL;
     }
+    
+    if ((a_ssize % 512) != 0) {
+        tsk_error_reset(); 
+        tsk_errno = TSK_ERR_IMG_ARG;
+        snprintf(tsk_errstr, TSK_ERRSTR_L, "sector size is not a multiple of 512 (%d)", a_ssize);
+        return NULL;
+    }
+    
 
     if (tsk_verbose)
         TFPRINTF(stderr,
-- 
GitLab