projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dns: implement tcp fallback in __res_msend query core
[musl]
/
src
/
network
/
getservbyname_r.c
diff --git
a/src/network/getservbyname_r.c
b/src/network/getservbyname_r.c
index
056c2f3
..
cad6317
100644
(file)
--- a/
src/network/getservbyname_r.c
+++ b/
src/network/getservbyname_r.c
@@
-5,6
+5,7
@@
#include <inttypes.h>
#include <errno.h>
#include <string.h>
#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 *))
#include "lookup.h"
#define ALIGN (sizeof(struct { char a; char *b; }) - sizeof(char *))
@@
-15,6
+16,13
@@
int getservbyname_r(const char *name, const char *prots,
struct service servs[MAXSERVS];
int cnt, proto, align;
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)
/* Align buffer */
align = -(uintptr_t)buf & ALIGN-1;
if (buflen < 2*sizeof(char *)+align)