fdisk: off-by-one issue in (n)new command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think I found two related bugs, steps to reproduce will be more clear than a description: It is present in stable 2.20.1 and using latest git snapshot, and using any device/file as disk, using here a loop dev with a backing file of 256MiB just for example.

### This how looks using default values (correct):

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-524287, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-524287, default 524287):
Using default value 524287
Partition 1 of type Linux and of size 255 MiB is set

Command (m for help): p

Disk /dev/loop0: 268 MB, 268435456 bytes
255 heads, 63 sectors/track, 32 cylinders, total 524288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe020b0b1

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1            2048      524287      261120   83  Linux

Command (m for help):

### Now, instead of accepting default value of "last sector", specify one that just fits (+255M, +261120K), fdisk says "out of range", and now I want to use default value (leaving blank or just wrinting it is the same behaviour) (see how fdisk says that using default value of 524287, but 524286 is used instead)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-524287, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-524287, default 524287): +255M
Value out of range.
Last sector, +sectors or +size{K,M,G} (2048-524287, default 524287):
Using default value 524287
Partition 1 of type Linux and of size 255 MiB is set

Command (m for help): p

Disk /dev/loop0: 268 MB, 268435456 bytes
255 heads, 63 sectors/track, 32 cylinders, total 524288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe020b0b1

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1            2048      524286      261119+  83  Linux

Command (m for help):

### Or doing with +sectors format:
(in this case the default value is used as expected)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-524287, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-524287, default 524287): +522240
Value out of range.
Last sector, +sectors or +size{K,M,G} (2048-524287, default 524287):
Using default value 524287
Partition 1 of type Linux and of size 255 MiB is set

Command (m for help): p

Disk /dev/loop0: 268 MB, 268435456 bytes
255 heads, 63 sectors/track, 32 cylinders, total 524288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe020b0b1

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1            2048      524287      261120   83  Linux

Command (m for help):

--
Gerardo Exequiel Pozzi
\cos^2\alpha + \sin^2\alpha = 1

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux