Skip to content

Commit

Permalink
Merge pull request #93 from Mellvik/misc
Browse files Browse the repository at this point in the history
[cmd] Prevent fdisk from creating partition beyond end of medium.
  • Loading branch information
Mellvik authored Oct 19, 2024
2 parents a107b99 + 1f091b1 commit d02676a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tlvccmd/disk_utils/fdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ void add_part(void)
oset = MBR + PARTITION_START + ((part - 1) * 16);

printf("Total cylinders: %d\n", geometry.cylinders);
for (scyl = geometry.cylinders + 1; scyl < 0 || scyl > geometry.cylinders;) {
printf("First cylinder (%d-%d): ", 0, geometry.cylinders);
for (scyl = geometry.cylinders; scyl < 0 || scyl > geometry.cylinders-1;) {
printf("First cylinder (%d-%d): ", 0, geometry.cylinders-1);
fflush(stdout);
fgets(buf, 31, stdin);
scyl = atoi(buf);
Expand All @@ -187,8 +187,8 @@ void add_part(void)
p.cyl = (scyl & 0xff);
p.sys_ind = PARTITION_TYPE;

for (ecyl = geometry.cylinders + 1; ecyl < scyl || ecyl > geometry.cylinders;) {
printf("Ending cylinder (%d-%d): ", 0, geometry.cylinders);
for (ecyl = geometry.cylinders; ecyl < scyl || ecyl > geometry.cylinders-1;) {
printf("Ending cylinder (%d-%d): ", 0, geometry.cylinders-1);
fflush(stdout);
fgets(buf, 31, stdin);
ecyl = atoi(buf);
Expand Down

0 comments on commit d02676a

Please sign in to comment.