tags 416477 +pending
thanks

On Wed, Mar 28, 2007 at 05:15:18AM -0400, A. Costa wrote:
> Package: e2fsprogs
> Version: 1.39+1.40-WIP-2006.11.14+dfsg-2
> Severity: normal
> 
> Error messages add one to a too low 'lastblock':
> 
>     % badblocks -vs /dev/hdb1 1 2
>     badblocks: invalid blocks range: 2-2
>     % badblocks -vs /dev/hdb1 1 99
>     badblocks: invalid blocks range: 99-2
> 
> Too high values vary more:
> 
>     % badblocks -vs /dev/hdb1 20000000000 3
>     badblocks: invalid blocks range: 3-0

Thanks for your bug report.  The following check has been checked into
e2fsprogs, and will be in the next release of e2fsprogs.

                                                - Ted

Fix error checking of badblock's last-block and start-block arguments

Addresses Debian Bug: #416477

Signed-off-by: "Theodore Ts'o" <[EMAIL PROTECTED]>

diff -r fad17bc88e5b -r 449d075befe0 misc/ChangeLog
--- a/misc/ChangeLog    Mon Jun 04 01:14:52 2007 -0400
+++ b/misc/ChangeLog    Mon Jun 04 01:49:51 2007 -0400
@@ -1,3 +1,8 @@ 2007-05-31  Theodore Tso  <[EMAIL PROTECTED]
+2007-06-04  Theodore Tso  <[EMAIL PROTECTED]>
+
+       * badblocks.c (main): Fix error checking of the last-block and
+               start-block arguments.  (Addresses Debian Bug: #416477)
+
 2007-05-31  Theodore Tso  <[EMAIL PROTECTED]>
 
        * mke2fs.c (parse_extended_opts): Free allocated buf on return
diff -r fad17bc88e5b -r 449d075befe0 misc/badblocks.c
--- a/misc/badblocks.c  Mon Jun 04 01:14:52 2007 -0400
+++ b/misc/badblocks.c  Mon Jun 04 01:49:51 2007 -0400
@@ -46,6 +46,7 @@ extern int optind;
 #include <unistd.h>
 #include <setjmp.h>
 #include <time.h>
+#include <limits.h>
 
 #include <sys/ioctl.h>
 #include <sys/types.h>
@@ -987,24 +988,31 @@ int main (int argc, char ** argv)
                        exit(1);
                }
        } else {
-               last_block = strtoul (argv[optind], &tmp, 0) + 1;
-               if (*tmp) {
+               errno = 0;
+               last_block = strtoul (argv[optind], &tmp, 0);
+               printf("last_block = %d (%s)\n", last_block, argv[optind]);
+               if (*tmp || errno || 
+                   (last_block == ULONG_MAX && errno == ERANGE)) {
                        com_err (program_name, 0, _("invalid blocks count - 
%s"),
                                 argv[optind]);
                        exit (1);
                }
+               last_block++;
                optind++;
        }
        if (optind <= argc-1) {
+               errno = 0;
                from_count = strtoul (argv[optind], &tmp, 0);
-               if (*tmp) {
+               printf("from_count = %d\n", from_count);
+               if (*tmp || errno ||
+                   (from_count == ULONG_MAX && errno == ERANGE)) {
                        com_err (program_name, 0, _("invalid starting block - 
%s"),
                                 argv[optind]);
                        exit (1);
                }
        } else from_count = 0;
        if (from_count >= last_block) {
-           com_err (program_name, 0, _("invalid blocks range: %lu-%lu"),
+           com_err (program_name, 0, _("invalid starting block (%d): must be 
less than %lu"),
                     (unsigned long) from_count, (unsigned long) last_block);
            exit (1);
        }


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to