diff options
author | wtc%netscape.com <devnull@localhost> | 1998-09-10 20:49:14 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 1998-09-10 20:49:14 +0000 |
commit | 9053d23f0bf4d03b5bc80b2ffe59bf1e4dc53825 (patch) | |
tree | 4c8bdd0804a0dc8ca67ba2e6c1efb43bae899c62 | |
parent | 3e3a7bafc0a96e5929d66d73a78bdfcca0c79318 (diff) | |
download | nspr-hg-9053d23f0bf4d03b5bc80b2ffe59bf1e4dc53825.tar.gz |
In CreateMacPathFromUnixPath, the length of the macPath buffer
should be (strlen(unixPath) + 2) instead of (strlen(unixPath) * 2).
This is because for a zero-length unixPath, the macPath is ":",
which needs two bytes. Thanks to Patrick Beard <beard@netscape.com>
and Steve Dagley <sdagley@netscape.com> for reporting the bug and
suggesting a fix.
-rw-r--r-- | pr/src/md/mac/macio.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/pr/src/md/mac/macio.c b/pr/src/md/mac/macio.c index 96fe38c4..f0e393bc 100644 --- a/pr/src/md/mac/macio.c +++ b/pr/src/md/mac/macio.c @@ -1040,16 +1040,17 @@ static OSErr CreateMacPathFromUnixPath(const char *unixPath, char **macPath) // It does not do any special directory translation; use ConvertUnixPathToMacPath // for that. - char *src; + const char *src; char *tgt; OSErr err = noErr; - *macPath = malloc(strlen(unixPath) * 2); // Will be enough extra space. + // If unixPath is a zero-length string, we copy ":" into + // macPath, so we need a minimum of two bytes to handle + // the case of ":". + *macPath = malloc(strlen(unixPath) + 2); // Will be enough extra space. require_action (*macPath != NULL, exit, err = memFullErr;); - strcpy(*macPath, ""); // Clear the Mac path - - (const char *)src = unixPath; + src = unixPath; tgt = *macPath; if (PL_strchr(src, PR_DIRECTORY_SEPARATOR) == src) // If weĠre dealing with an absolute @@ -1607,16 +1608,17 @@ static OSErr CreateMacPathFromUnixPath(const char *unixPath, char **macPath) // It does not do any special directory translation; use ConvertUnixPathToMacPath // for that. - char *src; + const char *src; char *tgt; OSErr err = noErr; - *macPath = malloc(strlen(unixPath) * 2); // Will be enough extra space. + // If unixPath is a zero-length string, we copy ":" into + // macPath, so we need a minimum of two bytes to handle + // the case of ":". + *macPath = malloc(strlen(unixPath) + 2); // Will be enough extra space. require_action (*macPath != NULL, exit, err = memFullErr;); - strcpy(*macPath, ""); // Clear the Mac path - - (const char *)src = unixPath; + src = unixPath; tgt = *macPath; if (PL_strchr(src, PR_DIRECTORY_SEPARATOR) == src) // If weĠre dealing with an absolute |