#include <inttypes.h>
#include <errno.h>
#include <string.h>
+#include <stdlib.h>
#include "lookup.h"
#define ALIGN (sizeof(struct { char a; char *b; }) - sizeof(char *))
struct service servs[MAXSERVS];
int cnt, proto, align;
+ *res = 0;
+
+ /* Don't treat numeric port number strings as service records. */
+ char *end = "";
+ strtoul(name, &end, 10);
+ if (!*end) return ENOENT;
+
/* Align buffer */
align = -(uintptr_t)buf & ALIGN-1;
if (buflen < 2*sizeof(char *)+align)
else if (!strcmp(prots, "udp")) proto = IPPROTO_UDP;
else return EINVAL;
- cnt = __lookup_serv(servs, name, proto, 0);
+ cnt = __lookup_serv(servs, name, proto, 0, 0);
if (cnt<0) switch (cnt) {
case EAI_MEMORY:
case EAI_SYSTEM: