Bug#416477: badblocks: 'invalid blocks range' inaccuracies.

2007-06-04 Thread Theodore Tso
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 200 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/ChangeLogMon Jun 04 01:14:52 2007 -0400
+++ b/misc/ChangeLogMon 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]



Bug#416477: badblocks: 'invalid blocks range' inaccuracies.

2007-03-28 Thread A. Costa
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 200 3
badblocks: invalid blocks range: 3-0
% badblocks -vs /dev/hdb1 20 200
badblocks: invalid blocks range: 4294967295-21
% badblocks -vs /dev/hdb1 2 200
badblocks: invalid blocks range: 4294967295-0

If the error ranges were correct that'd fix this bug, though it'd be
ideal (wishlist?) if the 'invalid blocks range' messages were
informative and conditional, perhaps like:

badblocks: error, lastblock '1' is less than startblock '2'

badblocks: error, lastblock '2' is greater than the /dev/hdb1 
maximum of 9518480.


Hope this helps...


-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.18-3-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C)

Versions of packages e2fsprogs depends on:
ii  e2fslibs 1.39+1.40-WIP-2006.11.14+dfsg-2 ext2 filesystem libraries
ii  libblkid 1.39+1.40-WIP-2006.11.14+dfsg-2 block device id library
ii  libc62.3.6.ds1-13GNU C Library: Shared libraries
ii  libcomer 1.39+1.40-WIP-2006.11.14+dfsg-2 common error description library
ii  libss2   1.39+1.40-WIP-2006.11.14+dfsg-2 command-line interface parsing lib
ii  libuuid1 1.39+1.40-WIP-2006.11.14+dfsg-2 universally unique id library

e2fsprogs recommends no packages.

-- no debconf information


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