Package: u3-tool
Version: 0.3-1.1
Severity: important
Tags: patch

Dear Maintainer,

Got a u3 capable flash memory from a friend. In the first attempt to
learn about the drive and u3-tool:

# u3-tool -i /dev/sdb
Total device size:   953.50 MB (999817216 bytes)
Segmentation fault

Thing is, print_human_size cannot deal with a size of less than
1024. Expected output:

# u3-tool -i /dev/sdb
Total device size:   953.50 MB (999817216 bytes)
CD size:             0.00  B (0 bytes)
Data partition size: 953.50 MB (999817216 bytes)


Here's how to fix:

--- a/src/main.c
+++ b/src/main.c
@@ -110,7 +110,7 @@ void print_human_size(uint64_t size) {
                factor++;
        }
 
-       printf("%.2f %cB", fsize, factor_symbols[factor-1]);
+       printf("%.2f %cB", fsize, factor > 0 ? factor_symbols[factor-1] : ' ');
 }
 
 /**

Regards,
    Christoph

-- System Information:
Debian Release: 7.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.10.17 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Attachment: signature.asc
Description: Digital signature

Reply via email to