Bug 4423 - speed_table has insufficient field size for termios speed values
Summary: speed_table has insufficient field size for termios speed values
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.19.x
Hardware: PC Other
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-30 20:22 UTC by Michael Tokarev
Modified: 2014-02-27 12:38 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Tokarev 2011-10-30 20:22:16 UTC
In libb/speed_table,c, speed_map struct uses two short integers (unsigned short) to hold both speed and internal "value".  But at least on BSD, unsigned short is not sufficient to hold actual speed constant:

        {B115200, 115200/256 + 0x8000U},
        {B230400, 230400/256 + 0x8000U},
        {B460800, 460800/256 + 0x8000U},

from FreeBSD /usr/include/bits/termios.h:

#define B115200 115200
#define B230400 230400
#define B460800 460800

which does not fit in unsigned short, which is 65535 max.

I'm not sure what to do here, maybe change both to integer (from short integer), or use an inline switch stateent...
Comment 1 Denys Vlasenko 2014-02-27 12:37:45 UTC
Fixed in git:

commit 96f92a1afac1599cc5f6128e7e9a43bdab220bc8
Author: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Wed Jan 8 15:25:20 2014 +0100

    libbb: FreeBSD fix for B<num> baud rate constants not fitting into a short.