diff options
author | Tomas Mraz <tmraz@fedoraproject.org> | 2020-11-03 18:34:16 +0100 |
---|---|---|
committer | Tomas Mraz <tmraz@fedoraproject.org> | 2020-11-11 16:06:30 +0100 |
commit | 368d9e030fac7355f0d1d24fb5059bf0c848fe4f (patch) | |
tree | 8ee01c7c08531fa87a5acd2f0c14b722d727b355 /include/internal/cryptlib.h | |
parent | Avoid duplicate ends_with_dirsep functions (diff) | |
download | openssl-368d9e030fac7355f0d1d24fb5059bf0c848fe4f.tar.xz openssl-368d9e030fac7355f0d1d24fb5059bf0c848fe4f.zip |
Add ossl_is_absolute_path function to detect absolute paths
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13306)
Diffstat (limited to '')
-rw-r--r-- | include/internal/cryptlib.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/internal/cryptlib.h b/include/internal/cryptlib.h index f1c6ddfd30..eae10dfb6c 100644 --- a/include/internal/cryptlib.h +++ b/include/internal/cryptlib.h @@ -267,4 +267,20 @@ static ossl_inline int ossl_ends_with_dirsep(const char *path) return *path == '/'; } +static ossl_inline int ossl_is_absolute_path(const char *path) +{ +# if defined __VMS + if (strchr(path, ':') != NULL + || ((path[0] == '[' || path[0] == '<') + && path[1] != '.' && path[1] != '-' + && path[1] != ']' && path[1] != '>')) + return 1; +# elif defined _WIN32 + if (path[0] == '\\' + || (path[0] != '\0' && path[1] == ':')) + return 1; +# endif + return path[0] == '/'; +} + #endif |