random output when size_to_str() passed values larger than 10^28

Bug #1059783 reported by James Hunt
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

# correct output ("10000 Y" or 10k yottabytes)
$ python2.7 -c 'import apt_pkg; print(apt_pkg.size_to_str(10 ** 28))' |od -xc
0000000 3031 3030 2030 0a59
          1 0 0 0 0 Y \n
0000010

# incorrect output: random output!
$ python2.7 -c 'import apt_pkg; print(apt_pkg.size_to_str(10 ** 29))' |od -xc
0000000 75b0 01ff 8020 b74c 000a
        260 u 377 001 200 L 267 \n
0000011

Admittedly, it'll probably be a while before this becomes an issue ;-)

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-apt (Ubuntu):
status: New → Confirmed
Revision history for this message
Barry Warsaw (barry) wrote :

This affects me because my hard drive goes to 11.

Changed in python-apt (Ubuntu):
importance: Undecided → Low
Revision history for this message
Colin Watson (cjwatson) wrote :

Reproducible with a C++ program linked against libapt-pkg.

#include <apt-pkg/strutl.h>
#include <stdio.h>

void show(double size)
{
    std::string out = SizeToStr(size);
    printf("SizeToStr(%f) = '%s'\n", size, out.c_str());
}

int main()
{
    show(100000000000000000000000000000.0L);
    return 0;
}

affects: python-apt (Ubuntu) → apt (Ubuntu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.