Bug 4423

Summary: speed_table has insufficient field size for termios speed values
Product: Busybox Reporter: Michael Tokarev <mjt+busybox>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: minor CC: busybox-cvs
Priority: P5    
Version: 1.19.x   
Target Milestone: ---   
Hardware: PC   
OS: Other   
Host: Target:
Build:

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.