mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-05-02 12:39:38 +00:00
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)
This commit is contained in:
parent
69d16b70cf
commit
368d9e030f
@ -2,8 +2,8 @@
|
||||
|
||||
=head1 NAME
|
||||
|
||||
ossl_ends_with_dirsep - internal function to detect whether a path
|
||||
ends with directory separator
|
||||
ossl_ends_with_dirsep, ossl_is_absolute_path
|
||||
- internal functions to work with paths
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
@ -11,19 +11,26 @@ ends with directory separator
|
||||
|
||||
int ossl_ends_with_dirsep(const char *path);
|
||||
|
||||
int ossl_is_absolute_path(const char *path);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
ossl_ends_with_dirsep() detects whether the I<path> ends with a directory
|
||||
separator in platform agnostic way.
|
||||
separator in a platform agnostic way.
|
||||
|
||||
ossl_is_absolute_path() detects whether the I<path> is absolute path in
|
||||
a platform agnostic way.
|
||||
|
||||
=head1 RETURN VALUES
|
||||
|
||||
ossl_ends_with_dirsep() returns 1 if the I<path> ends with a directory
|
||||
separator, 0 otherwise.
|
||||
|
||||
ossl_is_absolute_path() returns 1 if the I<path> is absolute, 0 otherwise.
|
||||
|
||||
=head1 HISTORY
|
||||
|
||||
The function described here was added in OpenSSL 3.0.
|
||||
The functions described here were added in OpenSSL 3.0.
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user