off-by-one error in end cylinder LBA conversion

CHS and LBA values of partition end sector get out of sync with cylinder value one to high resulting in overlapping partitions etc. I think this results from an off-by-one error in LBA to CHS conversion at https://gitlab.com/FreeDOS/base/fdisk/-/blob/master/SOURCE/FDISK/FDISK/PDISKIO.C#L919 which gets triggered if the partition ends at a cylinder boundary. Adding -1 should correct the error:

pDrive->pri_part[index].end_cyl
           =Extract_Cylinder_From_LBA_Value(
           /* */
           (pDrive->pri_part[index].rel_sect
           +pDrive->pri_part[index].num_sect - 1)...

The error only occurs if FDISK is working in LBA mode.

Edited by Bernd Böckmann