Navigation


Changeset 1414:f6f12521c2aa in freeDiameter


Ignore:
Timestamp:
Feb 18, 2020, 5:01:49 PM (4 years ago)
Author:
Luke Mewburn <luke@mewburn.net>
Branch:
default
Phase:
public
committer:
Luke Mewburn <luke@mewburn.net> 1582020002 -39600
Message:

Fix strict-aliasing warnings with gcc 4.8

Rewrite IN6_ADDR_V4MAP() to not rely upon aliasing rules.
Add test for IN6_ADDR_V4MAP() and IN6_ADDR_V4UNMAP().

Rewrite MD5Final() to not rely upon aliasing rules. (Not tested)

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_radgw/md5.c

    r1291 r1414  
    287287
    288288    /* Append length in bits and transform */
    289     ((u32 *) ctx->in)[14] = ctx->bits[0];
    290     ((u32 *) ctx->in)[15] = ctx->bits[1];
     289    os_memcpy(&ctx->in[56], &ctx->bits[0], 8);
    291290
    292291    MD5Transform(ctx->buf, (u32 *) ctx->in);
  • extensions/app_sip/md5.c

    r1291 r1414  
    310310
    311311    /* Append length in bits and transform */
    312     ((u32 *) ctx->in)[14] = ctx->bits[0];
    313     ((u32 *) ctx->in)[15] = ctx->bits[1];
     312    os_memcpy(&ctx->in[56], &ctx->bits[0], 8);
    314313
    315314    MD5Transform(ctx->buf, (u32 *) ctx->in);
  • include/freeDiameter/libfdproto.h

    r1407 r1414  
    690690/* create a V4MAPPED address */
    691691#define IN6_ADDR_V4MAP( a6, a4 ) {                      \
    692         ((uint32_t *)(a6))[0] = 0;                      \
    693         ((uint32_t *)(a6))[1] = 0;                      \
    694         ((uint32_t *)(a6))[2] = htonl(0xffff);          \
    695         ((uint32_t *)(a6))[3] = (uint32_t)(a4);         \
     692        memset(&(*a6)[0], 0, 10);                       \
     693        (*a6)[10] = 0xff;                               \
     694        (*a6)[11] = 0xff;                               \
     695        memcpy(&(*a6)[12], &a4, 4);                     \
    696696}
    697697
  • tests/testmesg.c

    r1300 r1414  
    14491449                }
    14501450        }
     1451
     1452        /* Check IPv4 -> IPv6 and IPv6->IPv4 mapping */
     1453        {
     1454                struct in_addr i4;
     1455                memset(&i4, 0xff, sizeof(i4));
     1456                CHECK( 1, inet_pton( AF_INET, TEST_IP4, &i4 ) );
     1457
     1458                #define TEST_IP6MAP "::ffff:" TEST_IP4
     1459
     1460                struct in6_addr i6;
     1461                memset(&i6, 0xff, sizeof(i6));
     1462                IN6_ADDR_V4MAP(&i6.s6_addr, i4.s_addr);
     1463                char buf6[INET6_ADDRSTRLEN];
     1464                CHECK( 0, (inet_ntop( AF_INET6, &i6, buf6, sizeof(buf6) ) == NULL) ? errno : 0 );
     1465                LOG_D("buf6='%s'", buf6);
     1466                CHECK( 0, strcasecmp( buf6, TEST_IP6MAP ) );
     1467
     1468                struct in_addr o4;
     1469                o4.s_addr = IN6_ADDR_V4UNMAP(&i6);
     1470                char buf4[INET_ADDRSTRLEN];
     1471                CHECK( 0, (inet_ntop( AF_INET, &o4.s_addr, buf4, sizeof(buf4) ) == NULL) ? errno : 0 );
     1472                CHECK( 0, strcmp( buf4, TEST_IP4 ) );
     1473        }
    14511474       
    14521475        /* That's all for the tests yet */
Note: See TracChangeset for help on using the changeset viewer.