[Bug 273192] [PATCH] Distextract tries to divide by 0
Date: Fri, 18 Aug 2023 03:40:31 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273192 Bug ID: 273192 Summary: [PATCH] Distextract tries to divide by 0 Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: lars@oddbit.com Created attachment 244181 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=244181&action=edit Patch to prevent floating point exception in distextract In the file ./usr.sbin/bsdinstall/distextract/distextract.c, we find: /* Calculate [overall] percentage of completion (if possible) */ if (file->size >= 0) return (file->read * 100 / file->size); else return (-1); That conditional is incorrect; if distextract encounters a zero-length file, it will attempt to divide by file->size, which is 0, which will cause distextract fail error out with: Floating point exception (core dumped) The attached patch prevents this error. Addendum: I'm unclear why we use distextract. The "script" automated install script already includes an alternate code path that uses tar if the install isn't running on a tty; if we used this in all cases we could completely drop distextract. -- You are receiving this mail because: You are the assignee for the bug.