summaryrefslogtreecommitdiff
path: root/lib/libc/net/gethostnamadr.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-04-15 11:27:57 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-04-15 11:27:57 +0000
commit5be4e63f1c04acb5b8bcc43926d2ed655f95d00a (patch)
tree18b0acc7ecf60b0a3a6202f35bc3ace8c6dde973 /lib/libc/net/gethostnamadr.c
parentc30829eddbd1203f1d5a231e9c5a28a40e8d367e (diff)
correct the paranoia check
Diffstat (limited to 'lib/libc/net/gethostnamadr.c')
-rw-r--r--lib/libc/net/gethostnamadr.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c
index 7ce0f9c3bd4..95e00484d60 100644
--- a/lib/libc/net/gethostnamadr.c
+++ b/lib/libc/net/gethostnamadr.c
@@ -52,7 +52,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.21 1997/04/14 06:57:44 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.22 1997/04/15 11:27:56 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -140,15 +140,18 @@ _hokchar(p)
* characters are a-z, A-Z, 0-9, '-' and . But the others
* tested for below can happen, and we must be more permissive
* than the resolver until those idiots clean up their act.
+ * We let '/' through, but not '..'
*/
while ((c = *p++)) {
- if (('a' >= c && c <= 'z') ||
- ('A' >= c && c <= 'Z') ||
- ('0' >= c && c <= '9'))
+ if (('a' <= c && c <= 'z') ||
+ ('A' <= c && c <= 'Z') ||
+ ('0' <= c && c <= '9'))
continue;
- if (strchr("-_/.[]\\", c) ||
- (c == '.' && p[1] == '.'))
- return 0;
+ if (strchr("-_/", c))
+ continue;
+ if (c == '.' && *p != '.')
+ continue;
+ return 0;
}
return 1;
}