• Peter Hutterer's avatar
    include: introduce byte counting functions. · 3937db18
    Peter Hutterer authored
    This patch adds the following three functions:
     bits_to_bytes(bits) - the number of bytes needed to hold 'bits'
     bytes_to_int32(bytes) - the number of 4-byte units to hold 'bytes'
     pad_to_int32(bytes) - the closest multiple of 4 equal to or larger than
                            'bytes'.
    
    All three operations are common in protocol processing and currently the
    server has ((foo + 7)/8 + 3)/4 operations all over the place. A common set
    of functions reduce the error rate of these (albeit simple) calculations and
    improve readability of the code.
    
    The functions do not check for overflow.
    
    v2: backport to nx-libs 3.6.x as a prereq for
    the CVE-2015-0255 fix (Mike DePaulo)
    Signed-off-by: 's avatarPeter Hutterer <peter.hutterer@who-t.net>
    3937db18
Name
Last commit
Last update
bin Loading commit data...
debian Loading commit data...
doc/nx-X11_vs_XOrg69_patches Loading commit data...
etc Loading commit data...
nx-X11 Loading commit data...
nxcomp Loading commit data...
nxcompext Loading commit data...
nxcompshad Loading commit data...
nxproxy Loading commit data...
COPYING Loading commit data...
ChangeLog Loading commit data...
Makefile Loading commit data...
README.NX-development Loading commit data...
README.keystrokes Loading commit data...
VERSION Loading commit data...
VERSION.x2goagent Loading commit data...
nx-libs.spec Loading commit data...
replace.sh Loading commit data...
version.sh Loading commit data...