summaryrefslogtreecommitdiff
path: root/vms
diff options
context:
space:
mode:
authorCharles Bailey <bailey@newman.upenn.edu>2000-05-25 03:10:36 +0000
committerbailey <bailey@newman.upenn.edu>2000-05-25 03:10:36 +0000
commita2a900195eaa6a86b7c76db810e225ef84e2936f (patch)
tree2a10661554d92d75ce4171fc0c2017bc7a0a628e /vms
parent744a34f9085790ea7e2e782a67280c43116f938e (diff)
downloadperl-a2a900195eaa6a86b7c76db810e225ef84e2936f.tar.gz
Add bounds checking for several strings (Charles Lane)
p4raw-id: //depot/vmsperl@6115
Diffstat (limited to 'vms')
-rw-r--r--vms/vms.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/vms/vms.c b/vms/vms.c
index f3448bb11e..ca8b02a1f2 100644
--- a/vms/vms.c
+++ b/vms/vms.c
@@ -897,6 +897,9 @@ my_mkdir(char *dir, Mode_t mode)
STRLEN dirlen = strlen(dir);
dTHX;
+ /* zero length string sometimes gives ACCVIO */
+ if (dirlen == 0) return -1;
+
/* CRTL mkdir() doesn't tolerate trailing /, since that implies
* null file name/type. However, it's commonplace under Unix,
* so we'll allow it for a gain in portability.
@@ -1484,7 +1487,7 @@ static char *do_fileify_dirspec(char *dir,char *buf,int ts)
set_errno(EINVAL); set_vaxc_errno(SS$_BADPARAM); return NULL;
}
dirlen = strlen(dir);
- while (dir[dirlen-1] == '/') --dirlen;
+ while (dirlen && dir[dirlen-1] == '/') --dirlen;
if (!dirlen) { /* We had Unixish '/' -- substitute top of current tree */
strcpy(trndir,"/sys$disk/000000");
dir = trndir;
@@ -1510,7 +1513,7 @@ static char *do_fileify_dirspec(char *dir,char *buf,int ts)
* ... do_fileify_dirspec("myroot",buf,1) ...
* does something useful.
*/
- if (!strcmp(dir+dirlen-2,".]")) {
+ if (dirlen >= 2 && !strcmp(dir+dirlen-2,".]")) {
dir[--dirlen] = '\0';
dir[dirlen-1] = ']';
}
@@ -1540,7 +1543,7 @@ static char *do_fileify_dirspec(char *dir,char *buf,int ts)
(dir[2] == '\0' || (dir[2] == '/' && dir[3] == '\0')))
return do_fileify_dirspec("[-]",buf,ts);
}
- if (dir[dirlen-1] == '/') { /* path ends with '/'; just add .dir;1 */
+ if (dirlen && dir[dirlen-1] == '/') { /* path ends with '/'; just add .dir;1 */
dirlen -= 1; /* to last element */
lastdir = strrchr(dir,'/');
}
@@ -1567,7 +1570,7 @@ static char *do_fileify_dirspec(char *dir,char *buf,int ts)
} while ((cp1 = strstr(cp1,"/.")) != NULL);
lastdir = strrchr(dir,'/');
}
- else if (!strcmp(&dir[dirlen-7],"/000000")) {
+ else if (dirlen >= 7 && !strcmp(&dir[dirlen-7],"/000000")) {
/* Ditto for specs that end in an MFD -- let the VMS code
* figure out whether it's a real device or a rooted logical. */
dir[dirlen] = '/'; dir[dirlen+1] = '\0';