diff options
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 21 |
1 files changed, 20 insertions, 1 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.132 2018/10/03 06:38:35 djm 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. |
@@ -1948,6 +1948,25 @@ bad: | |||
1948 | return 0; | 1948 | return 0; |
1949 | } | 1949 | } |
1950 | 1950 | ||
1951 | /* | ||
1952 | * Verify that a environment variable name (not including initial '$') is | ||
1953 | * valid; consisting of one or more alphanumeric or underscore characters only. | ||
1954 | * Returns 1 on valid, 0 otherwise. | ||
1955 | */ | ||
1956 | int | ||
1957 | valid_env_name(const char *name) | ||
1958 | { | ||
1959 | const char *cp; | ||
1960 | |||
1961 | if (name[0] == '\0') | ||
1962 | return 0; | ||
1963 | for (cp = name; *cp != '\0'; cp++) { | ||
1964 | if (!isalnum((u_char)*cp) && *cp != '_') | ||
1965 | return 0; | ||
1966 | } | ||
1967 | return 1; | ||
1968 | } | ||
1969 | |||
1951 | const char * | 1970 | const char * |
1952 | atoi_err(const char *nptr, int *val) | 1971 | atoi_err(const char *nptr, int *val) |
1953 | { | 1972 | { |