Your message dated Mon, 21 Dec 2020 12:22:46 +0100
with message-id <[email protected]>
and subject line This issue seems managed since ages
has caused the Debian Bug report #699775,
regarding proftpd-basic: Wrong filesystem size in welcome message
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
699775: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699775
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: proftpd-basic
Severity: minor
Tags: upstream patch

Hi!

proftpd prints the wrong unit prefix if you put "%f" in your welcome
message, it's always an order of magnitude too large, e.g., 500TB
instead of 500GB.

The culprit is format_size_str() in src/display.c, the i variable is
always off by one. Note that you could also do a "i--;" after the while
loop, however, for the corner case of filesystems smaller than 1KB, this
would result in "i == -1" which would be "MAX_INT" given its current
"unsigned declaration".

I hence took the liberty to convert it to signed, start at -1 and
increment it in every iteration, so the index into the units[] array
remains correct.

I also dropped the "register" qualifier, the compiler would choose it
anyway if appropriate.

Please forward this patch to upstream, I don't want to deal with its
bugtracker. I assume that the Debian package maintainer is already in
permament contact with upstream. ;)


Cheers

-- System Information:
Debian Release: 7.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.7.4 (SMP w/8 CPU cores; PREEMPT)
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to 
en_US.UTF-8)
Shell: /bin/sh linked to /bin/dash
From: Adrian Knoth <[email protected]>
Description: Fix unit prefix in reported filesystem size
 The format_size_str() function contains an off-by-one error when
 calculating the proper Kilo/Mega/Giga... prefix.
--- a/src/display.c
+++ b/src/display.c
@@ -34,13 +34,13 @@ static const char *prev_msg = NULL;
 
 static void format_size_str(char *buf, size_t buflen, off_t size) {
   char units[] = {'K', 'M', 'G', 'T', 'P'};
-  register unsigned int i = 0;
+  int i = -1;
 
   /* Determine the appropriate units label to use. */
-  while (size > 1024) {
+  do {
     size /= 1024;
     i++;
-  }
+  } while (size > 1024);
 
   /* Now, prepare the buffer. */
   snprintf(buf, buflen, "%.3" PR_LU "%cB", (pr_off_t) size, units[i]);

--- End Message ---
--- Begin Message ---
Package: proftpd-dfsg
Version: 1.3.5b-1

This minor issue seems fixedi upstream since 1.3.5b or any later version.
Thanks.

--
Francesco P. Lovergine

--- End Message ---

Reply via email to