diff options
author | Colin Watson <cjwatson@debian.org> | 2018-10-19 21:29:01 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2018-10-19 21:29:01 +0100 |
commit | 3d246f10429fc9a37b98eabef94fe8dc7c61002b (patch) | |
tree | 1f35b42b5e5f462d35ba452e4dcfa188ce0543fd /misc.c | |
parent | e6547182a54f0f268ee36e7c99319eeddffbaff2 (diff) | |
parent | aede1c34243a6f7feae2fb2cb686ade5f9be6f3d (diff) |
Import openssh_7.9p1.orig.tar.gz
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: misc.c,v 1.131 2018/07/27 05:13:02 dtucker Exp $ */ | 1 | /* $OpenBSD: misc.c,v 1.133 2018/10/05 14:26:09 naddy Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. | 4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. |
@@ -50,6 +50,7 @@ | |||
50 | #include <netinet/in_systm.h> | 50 | #include <netinet/in_systm.h> |
51 | #include <netinet/ip.h> | 51 | #include <netinet/ip.h> |
52 | #include <netinet/tcp.h> | 52 | #include <netinet/tcp.h> |
53 | #include <arpa/inet.h> | ||
53 | 54 | ||
54 | #include <ctype.h> | 55 | #include <ctype.h> |
55 | #include <errno.h> | 56 | #include <errno.h> |
@@ -332,13 +333,16 @@ pwcopy(struct passwd *pw) | |||
332 | int | 333 | int |
333 | a2port(const char *s) | 334 | a2port(const char *s) |
334 | { | 335 | { |
336 | struct servent *se; | ||
335 | long long port; | 337 | long long port; |
336 | const char *errstr; | 338 | const char *errstr; |
337 | 339 | ||
338 | port = strtonum(s, 0, 65535, &errstr); | 340 | port = strtonum(s, 0, 65535, &errstr); |
339 | if (errstr != NULL) | 341 | if (errstr == NULL) |
340 | return -1; | 342 | return (int)port; |
341 | return (int)port; | 343 | if ((se = getservbyname(s, "tcp")) != NULL) |
344 | return ntohs(se->s_port); | ||
345 | return -1; | ||
342 | } | 346 | } |
343 | 347 | ||
344 | int | 348 | int |
@@ -1948,6 +1952,25 @@ bad: | |||
1948 | return 0; | 1952 | return 0; |
1949 | } | 1953 | } |
1950 | 1954 | ||
1955 | /* | ||
1956 | * Verify that a environment variable name (not including initial '$') is | ||
1957 | * valid; consisting of one or more alphanumeric or underscore characters only. | ||
1958 | * Returns 1 on valid, 0 otherwise. | ||
1959 | */ | ||
1960 | int | ||
1961 | valid_env_name(const char *name) | ||
1962 | { | ||
1963 | const char *cp; | ||
1964 | |||
1965 | if (name[0] == '\0') | ||
1966 | return 0; | ||
1967 | for (cp = name; *cp != '\0'; cp++) { | ||
1968 | if (!isalnum((u_char)*cp) && *cp != '_') | ||
1969 | return 0; | ||
1970 | } | ||
1971 | return 1; | ||
1972 | } | ||
1973 | |||
1951 | const char * | 1974 | const char * |
1952 | atoi_err(const char *nptr, int *val) | 1975 | atoi_err(const char *nptr, int *val) |
1953 | { | 1976 | { |