Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/networking/udhcp/domain_codec.c

    r2725 r3621  
    88 */
    99#ifdef DNS_COMPR_TESTING
     10# define _GNU_SOURCE
    1011# define FAST_FUNC /* nothing */
    1112# define xmalloc malloc
     
    4344    while (1) {
    4445        /* note: "return NULL" below are leak-safe since
    45          * dst isn't yet allocated */
     46         * dst isn't allocated yet */
    4647        const uint8_t *c;
    4748        unsigned crtpos, retpos, depth, len;
     
    6465                    return NULL;
    6566                if (dst)
    66                     memcpy(dst + len, c + 1, *c);
     67                    /* \3com ---> "com." */
     68                    ((char*)mempcpy(dst + len, c + 1, *c))[0] = '.';
    6769                len += *c + 1;
    6870                crtpos += *c + 1;
    69                 if (dst)
    70                     dst[len - 1] = '.';
    7171            } else {
    7272                /* NUL: end of current domain name */
     
    7979                    retpos = depth = 0;
    8080                }
    81                 if (dst)
     81                if (dst && len != 0)
     82                    /* \4host\3com\0\4host and we are at \0:
     83                     * \3com was converted to "com.", change dot to space.
     84                     */
    8285                    dst[len - 1] = ' ';
    8386            }
     
    9699            /* allocate dst buffer and copy pre */
    97100            unsigned plen = strlen(pre);
    98             ret = dst = xmalloc(plen + len);
    99             memcpy(dst, pre, plen);
    100             dst += plen;
     101            ret = xmalloc(plen + len);
     102            dst = stpcpy(ret, pre);
    101103        } else {
    102104            dst[len - 1] = '\0';
     
    229231    uint8_t *encoded;
    230232
     233        uint8_t str[6] = { 0x00, 0x00, 0x02, 0x65, 0x65, 0x00 };
     234        printf("NUL:'%s'\n",   dname_dec(str, 6, ""));
     235
    231236#define DNAME_DEC(encoded,pre) dname_dec((uint8_t*)(encoded), sizeof(encoded), (pre))
    232237    printf("'%s'\n",       DNAME_DEC("\4host\3com\0", "test1:"));
Note: See TracChangeset for help on using the changeset viewer.