-/* Read a label from a DNS packet, escape "\" and ".", append \0 */
-static gchar *escape_label(guint8* src, guint src_length, gchar **ret_name, guint *ret_name_length) {
- gchar *r;
-
- g_assert(src);
- g_assert(ret_name);
- g_assert(*ret_name);
- g_assert(ret_name_length);
- g_assert(*ret_name_length > 0);
-
- r = *ret_name;
-
- while (src_length > 0) {
- if (*src == '.' || *src == '\\') {
- if (*ret_name_length < 3)
- return NULL;
-
- *((*ret_name) ++) = '\\';
- (*ret_name_length) --;
- }
-
- if (*ret_name_length < 2)
- return NULL;
-
- *((*ret_name)++) = *src;
- (*ret_name_length) --;
-
- src_length --;
- src++;
- }
-
- **ret_name = 0;
-
- return r;
-}
-