diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2006-12-04 18:36:57 +0000 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2006-12-04 18:36:57 +0000 |
commit | 0d0cc2374ec0c63864b752eae72a5bcf294aa54e (patch) | |
tree | 4499005cea1e8ecee9273e31239553e69dd9604a /ldap/servers/slapd/util.c | |
parent | 0e6cd94b2023ef452a734cc4efba7a83d9ecc6c5 (diff) | |
download | ds-0d0cc2374ec0c63864b752eae72a5bcf294aa54e.tar.gz ds-0d0cc2374ec0c63864b752eae72a5bcf294aa54e.tar.xz ds-0d0cc2374ec0c63864b752eae72a5bcf294aa54e.zip |
Resolves: 158342
Summary: db backend path handling could be impoved to deal with "//", "..", etc.
Changes:
util.c:
modified rel2abspath so that if the given path contains "//", calls the
normalize function, and the normalize function eliminates the repeated
separators.
ldbm_config.c, ldbm_instance_config.c:
before setting the nsslapd-directory paths, pass them to rel2abspath to clean
up the paths.
Diffstat (limited to 'ldap/servers/slapd/util.c')
-rw-r--r-- | ldap/servers/slapd/util.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c index 0ef040d8..3145e736 100644 --- a/ldap/servers/slapd/util.c +++ b/ldap/servers/slapd/util.c @@ -61,9 +61,11 @@ #if defined( _WIN32 ) #define _PSEP "\\" +#define _PSEP2 "\\\\" #define _CSEP '\\' #else #define _PSEP "/" +#define _PSEP2 "//" #define _CSEP '/' #endif @@ -422,9 +424,9 @@ normalize_path(char *path) if (NULL == bnamep) { bnamep = dnamep; } else { - *bnamep = '\0'; - bnamep++; - } + *bnamep = '\0'; + bnamep++; + } if (0 != strcmp(bnamep, ".")) { *dp++ = slapi_ch_strdup(bnamep); /* remove "/./" in the path */ } @@ -447,9 +449,10 @@ normalize_path(char *path) if (rdp > rdirs) rdp--; } - if (*dp) + if (*dp && strlen(*dp) > 0) *rdp++ = slapi_ch_strdup(*dp); } + *rdp = NULL; clean_path(dirs); slapi_ch_free_string(&dname); @@ -518,14 +521,14 @@ rel2abspath_ext( char *relpath, char *cwd ) if ( abspath[ 0 ] != '\0' && abspath[ strlen( abspath ) - 1 ] != _CSEP ) { - PL_strcatn( abspath, sizeof(abspath), "/" ); + PL_strcatn( abspath, sizeof(abspath), _PSEP ); } PL_strcatn( abspath, sizeof(abspath), relpath ); } } retpath = slapi_ch_strdup(abspath); /* if there's no '.', no need to call normalize_path */ - if (NULL != strchr(abspath, '.')) + if (NULL != strchr(abspath, '.') || NULL != strstr(abspath, _PSEP2)) { char **norm_path = normalize_path(abspath); char **np, *rp; |