blob: 4f6eb0cd6f2cbb98fce61d7f06abbbf94cbb2e11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/* ISC license. */
#include <errno.h>
#include <skalibs/error.h>
#include <skalibs/bytestr.h>
#include "s6dns-message-internal.h"
int s6dns_message_get_string_internal (char *s, unsigned int max, char const *packet, unsigned int packetlen, unsigned int *pos)
{
register unsigned char len = ((unsigned char const *)packet)[*pos] ;
if (*pos + len + 1 > packetlen) return (errno = EPROTO, -1) ;
if (len > max) return (errno = ENAMETOOLONG, -1) ;
byte_copy(s, len, packet + *pos + 1) ;
*pos += len + 1 ;
return (int)len ;
}
|