summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc <devnull@localhost>1998-07-01 05:13:10 +0000
committerwtc <devnull@localhost>1998-07-01 05:13:10 +0000
commitc37de91f42dbd809af0de0eac8617871f9b26f5d (patch)
treecd2cd9ddd579e8f5567ef03e1166673fc34ef6e6
parent63ffdf90e758a5456255ad2b72b028ad2f4c28d3 (diff)
downloadnspr-hg-c37de91f42dbd809af0de0eac8617871f9b26f5d.tar.gz
In _PR_MD_OPEN_DIR, we append \*.* to the directory name,PLUGIN_MODULE_19980708_BASE
but if the directory name ends in a slash or backslash, we do not append the backslash. Files changed: ntio.c and w95io.c.
-rw-r--r--pr/src/md/windows/ntio.c19
-rw-r--r--pr/src/md/windows/w95io.c19
2 files changed, 34 insertions, 4 deletions
diff --git a/pr/src/md/windows/ntio.c b/pr/src/md/windows/ntio.c
index f2938b72..d3640995 100644
--- a/pr/src/md/windows/ntio.c
+++ b/pr/src/md/windows/ntio.c
@@ -2118,9 +2118,24 @@ PRStatus
_PR_MD_OPEN_DIR(_MDDir *d, const char *name)
{
char filename[ MAX_PATH ];
+ int len;
- PR_snprintf(filename, MAX_PATH, "%s%s%s",
- name, PR_DIRECTORY_SEPARATOR_STR, "*.*");
+ len = strlen(name);
+ /* Need 5 bytes for \*.* and the trailing null byte. */
+ if (len + 5 > MAX_PATH) {
+ PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);
+ return PR_FAILURE;
+ }
+ strcpy(filename, name);
+
+ /*
+ * If 'name' ends in a slash or backslash, do not append
+ * another backslash.
+ */
+ if (filename[len - 1] == '/' || filename[len - 1] == '\\') {
+ len--;
+ }
+ strcpy(&filename[len], "\\*.*");
FlipSlashes( filename, strlen(filename) );
d->d_hdl = FindFirstFile( filename, &(d->d_entry) );
diff --git a/pr/src/md/windows/w95io.c b/pr/src/md/windows/w95io.c
index 90811721..913d6ef9 100644
--- a/pr/src/md/windows/w95io.c
+++ b/pr/src/md/windows/w95io.c
@@ -349,9 +349,24 @@ PRStatus
_PR_MD_OPEN_DIR(_MDDir *d, const char *name)
{
char filename[ MAX_PATH ];
+ int len;
- PR_snprintf(filename, MAX_PATH, "%s%s%s",
- name, PR_DIRECTORY_SEPARATOR_STR, "*.*");
+ len = strlen(name);
+ /* Need 5 bytes for \*.* and the trailing null byte. */
+ if (len + 5 > MAX_PATH) {
+ PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);
+ return PR_FAILURE;
+ }
+ strcpy(filename, name);
+
+ /*
+ * If 'name' ends in a slash or backslash, do not append
+ * another backslash.
+ */
+ if (filename[len - 1] == '/' || filename[len - 1] == '\\') {
+ len--;
+ }
+ strcpy(&filename[len], "\\*.*");
FlipSlashes( filename, strlen(filename) );
d->d_hdl = FindFirstFile( filename, &(d->d_entry) );