Blame src/regression/dn_expand-ptr-0.c
|
Szabolcs Nagy |
d643f9 |
// dn_expand should handle offset pointer to 0 byte
|
|
Szabolcs Nagy |
d643f9 |
#define _BSD_SOURCE
|
|
Szabolcs Nagy |
d643f9 |
#include <resolv.h>
|
|
Szabolcs Nagy |
d643f9 |
#include <string.h>
|
|
Szabolcs Nagy |
d643f9 |
#include "test.h"
|
|
Szabolcs Nagy |
d643f9 |
|
|
Szabolcs Nagy |
d643f9 |
int main(void)
|
|
Szabolcs Nagy |
d643f9 |
{
|
|
Szabolcs Nagy |
d643f9 |
unsigned char packet[] = {2,'p','q',0xc0,5,0};
|
|
Szabolcs Nagy |
d643f9 |
char name[] = "XXXX";
|
|
Szabolcs Nagy |
d643f9 |
int r;
|
|
Szabolcs Nagy |
d643f9 |
|
|
Szabolcs Nagy |
d643f9 |
/* non-empty name with pointer to 0 */
|
|
Szabolcs Nagy |
d643f9 |
r = dn_expand(packet, packet+6, packet, name, 3);
|
|
Szabolcs Nagy |
d643f9 |
if (r!=5)
|
|
Szabolcs Nagy |
d643f9 |
t_error("dn_expand(\"\\2pq\\xc0\\5\", name, 3) returned %d, wanted 5\n", r);
|
|
Szabolcs Nagy |
d643f9 |
if (strcmp(name, "pq"))
|
|
Szabolcs Nagy |
d643f9 |
t_error("dn_expand(\"\\2pq\\xc0\\5\", name, 3) failed: got \"%s\" name, wanted \"pq\"\n", name);
|
|
Szabolcs Nagy |
d643f9 |
|
|
Szabolcs Nagy |
d643f9 |
/* empty name with pointer to 0 */
|
|
Szabolcs Nagy |
d643f9 |
memcpy(packet, "\xc0\2", 3);
|
|
Szabolcs Nagy |
d643f9 |
memcpy(name, "XXXX", 5);
|
|
Szabolcs Nagy |
d643f9 |
r = dn_expand(packet, packet+3, packet, name, 1);
|
|
Szabolcs Nagy |
d643f9 |
if (r!=2)
|
|
Szabolcs Nagy |
d643f9 |
t_error("dn_expand(\"\\xc0\\2\", name, 1) returned %d, wanted 2\n", r);
|
|
Szabolcs Nagy |
d643f9 |
if (name[0])
|
|
Szabolcs Nagy |
d643f9 |
t_error("dn_expand(\"\\xc0\\2\", name, 1) failed: got \"%s\" name, wanted \"\"\n", name);
|
|
Szabolcs Nagy |
d643f9 |
|
|
Szabolcs Nagy |
d643f9 |
return t_status;
|
|
Szabolcs Nagy |
d643f9 |
}
|