shithub: vdir

Download patch

ref: 2a931184d7e0d5a3cea1fa925619b51b69988464
parent: 8ffa802e29ca42eb54cc4b10f8c756ba6275e801
author: phil9 <telephil9@gmail.com>
date: Tue Oct 11 05:22:04 EDT 2022

fix floating point exception (thanks igor)

The logarithm of a negative number is undefined. To store the
file length the int data type is not sufficient as the file
length is represented by a vlong (see /sys/include/libc.h:657).

Overflowing an integer causes it to be interpreted as a negative
number, that in turn causes an exception when trying to compute
the log of a negative number.

To fix the issue the type of the variable storing the largest
file length needs to change from int to vlong.

--- a/vdir.c
+++ b/vdir.c
@@ -124,7 +124,8 @@
 void
 loaddirs(void)
 {
-	int fd, i, m;
+	int fd, i;
+	vlong m;
 
 	fd = open(path, OREAD);
 	if(fd<0){