Menu

#346 Bug Xcopy.exe can Fail when Destination Drive has 4+gb Free

freedos13
closed-fixed
nobody
5
2025-08-12
2021-08-12
Craig W
No

xcopy.exe (v1.4a and earlier) can fail when the destination drive has more than 4gb free space.

Source file xcopy.c @ line 756 calculates free disk space with -

  free_diskspace = (unsigned long) disktable.df_avail * disktable.df_sclus * disktable.df_bsec;

The free_diskspace unsigned long and cast overflows and wraps when it hits a 4 gigabyte boundary, e.g 4.1gb gets reported as 0.1gb. Will produce random "insufficient free space" errors even when a drive actually has enough free space.

There's several other code files that have the same flaw, probably worth auditing the code base for getdfree()/_dos_getdiskfree().

Cheers

Related

Bugs: #346

Discussion

  • Jim Hall

    Jim Hall - 2022-02-23
    • labels: --> xcopy, _dos_getdiskfree
     
  • fritz.mueller

    fritz.mueller - 2024-08-05

    This bug is still active on 2024-08-05! I just tried to copy bigger files (1,5 GB, should be no problem) on a 150 GB virtual HD where 141,541 MBytes are free!
    The first 10 of 16 files were done.

    There seems to be an uncompiled version 1.5 at: https://github.com/FDOS/xcopy

     

    Last edit: fritz.mueller 2024-08-05
  • fritz.mueller

    fritz.mueller - 2024-08-12

    Thank you very much! Seems to be fixed now!
    From my side the thread can be closed!

     
  • Jim Hall

    Jim Hall - 2025-08-12
    • status: open --> closed-fixed
     
    • fritz.mueller

      fritz.mueller - 2025-08-12

      just an additional comment:

      I added two different Linux iso files on an actual virtual FD machine
      which a drive letter that has full 2TB FAT32 capacity (Bernds kernel) -
      and ran xcopy to copy all files (ca. 3,9 GB and ca. 2 GB) on to this HD.
      It worked fine. I noticed not problems, no crash, nothing.

      So I think it was a good idea to close the bug.

      Fritz

      Am 2025-08-12 02:02, schrieb Jim Hall:

      • status: open --> closed-fixed
      • Comment:

      Marking as closed-fixed since XCOPY was updated in a later release to fix stack and disk space issues, as Fritz mentioned.

      [bugs:#346] [1] Bug Xcopy.exe can Fail when Destination Drive has 4+gb Free

      Status: closed-fixed
      Group: freedos13
      Labels: xcopy _dos_getdiskfree
      Created: Thu Aug 12, 2021 11:03 AM UTC by Craig W
      Last Updated: Mon Aug 12, 2024 12:29 PM UTC
      Owner: nobody

      xcopy.exe (v1.4a and earlier) can fail when the destination drive has more than 4gb free space.

      Source file xcopy.c @ line 756 calculates free disk space with -

      free_diskspace = (unsigned long) disktable.df_avail * disktable.df_sclus * disktable.df_bsec;

      The free_diskspace unsigned long and cast overflows and wraps when it hits a 4 gigabyte boundary, e.g 4.1gb gets reported as 0.1gb. Will produce random "insufficient free space" errors even when a drive actually has enough free space.

      There's several other code files that have the same flaw, probably worth auditing the code base for getdfree()/_dos_getdiskfree().

      Cheers

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/freedos/bugs/346/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

      [1] https://sourceforge.net/p/freedos/bugs/346/

       

      Related

      Bugs: #346

  • Jim Hall

    Jim Hall - 2025-08-12

    Marking as closed-fixed since XCOPY was updated in a later release to fix stack and disk space issues, as Fritz mentioned.

     

Log in to post a comment.

MongoDB Logo MongoDB