Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/networking/udhcp/domain_codec.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- 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 8 8 */ 9 9 #ifdef DNS_COMPR_TESTING 10 # define _GNU_SOURCE 10 11 # define FAST_FUNC /* nothing */ 11 12 # define xmalloc malloc … … 43 44 while (1) { 44 45 /* note: "return NULL" below are leak-safe since 45 * dst isn't yet allocated*/46 * dst isn't allocated yet */ 46 47 const uint8_t *c; 47 48 unsigned crtpos, retpos, depth, len; … … 64 65 return NULL; 65 66 if (dst) 66 memcpy(dst + len, c + 1, *c); 67 /* \3com ---> "com." */ 68 ((char*)mempcpy(dst + len, c + 1, *c))[0] = '.'; 67 69 len += *c + 1; 68 70 crtpos += *c + 1; 69 if (dst)70 dst[len - 1] = '.';71 71 } else { 72 72 /* NUL: end of current domain name */ … … 79 79 retpos = depth = 0; 80 80 } 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 */ 82 85 dst[len - 1] = ' '; 83 86 } … … 96 99 /* allocate dst buffer and copy pre */ 97 100 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); 101 103 } else { 102 104 dst[len - 1] = '\0'; … … 229 231 uint8_t *encoded; 230 232 233 uint8_t str[6] = { 0x00, 0x00, 0x02, 0x65, 0x65, 0x00 }; 234 printf("NUL:'%s'\n", dname_dec(str, 6, "")); 235 231 236 #define DNAME_DEC(encoded,pre) dname_dec((uint8_t*)(encoded), sizeof(encoded), (pre)) 232 237 printf("'%s'\n", DNAME_DEC("\4host\3com\0", "test1:"));
Note:
See TracChangeset
for help on using the changeset viewer.