[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: coturn - bus error on armhf



Hi!

On 12/23/18 10:03 AM, wferi@niif.hu wrote:
> Thanks to everybody for their spot-on comments, and especially to Steve
> for his detailed analysis in the bug report.  Meanwhile I reproduced the
> error on the sparc64 porterbox, but I couldn't really make head or tail
> of the issue at the source level, so that additional input is most
> appreciated.  We'll probably have to replace all nswap64 occurences in
> the code (at least).

I just ran the binary through gdb:

(gdb) bt
#0  0x000001000000d0e0 in encode_oauth_token_gcm (server_name=0x7feffffebd8 "blackdow.carleon.gov", etoken=0x7feffffe4b8, key=0x7feffffe100, dtoken=0x7feffffdbf0, 
    nonce0=0x7feffffeb78 "h4j3k2l2n4b5") at src/ns_turn_defs.h:98
#1  0x0000010000003778 in check_oauth () at src/apps/rfc5769/rfc5769check.c:146
#2  main (argc=<optimized out>, argv=<optimized out>) at src/apps/rfc5769/rfc5769check.c:568
(gdb)

Looking at the code, it's very obvious where the unaligned access
comes from. It's in src/ns_turn_defs.h:

static inline u64bits _ioa_ntoh64(u64bits v)
{
#if BYTE_ORDER == LITTLE_ENDIAN
        u08bits *src = (u08bits*) &v;
        u08bits* dst = src + 7;
        while (src < dst) {
                u08bits vdst = *dst;
                *(dst--) = *src;
                *(src++) = vdst;
        }
#elif BYTE_ORDER == BIG_ENDIAN
        /* OK */
#else
#error WRONG BYTE_ORDER SETTING
#endif
        return v;
}

The copying here needs to be done with memcpy(). Just casting pointers
and using plain assignment is a guarantee for unaligned access.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


Reply to: