summaryrefslogtreecommitdiff
path: root/usr/src/boot/lib/libstand/cd9660.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/boot/lib/libstand/cd9660.c')
-rw-r--r--usr/src/boot/lib/libstand/cd9660.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/usr/src/boot/lib/libstand/cd9660.c b/usr/src/boot/lib/libstand/cd9660.c
index 1e094450cd..487b994408 100644
--- a/usr/src/boot/lib/libstand/cd9660.c
+++ b/usr/src/boot/lib/libstand/cd9660.c
@@ -41,6 +41,7 @@
*/
#include <sys/param.h>
#include <string.h>
+#include <stdbool.h>
#include <sys/dirent.h>
#include <fs/cd9660/iso.h>
#include <fs/cd9660/cd9660_rrip.h>
@@ -226,8 +227,8 @@ static int
dirmatch(struct open_file *f, const char *path, struct iso_directory_record *dp,
int use_rrip, int lenskip)
{
- size_t len;
- char *cp;
+ size_t len, plen;
+ char *cp, *sep;
int i, icase;
if (use_rrip)
@@ -241,7 +242,14 @@ dirmatch(struct open_file *f, const char *path, struct iso_directory_record *dp,
} else
icase = 0;
- if (strlen(path) != len)
+ sep = strchr(path, '/');
+ if (sep != NULL) {
+ plen = sep - path;
+ } else {
+ plen = strlen(path);
+ }
+
+ if (plen != len)
return (0);
for (i = len; --i >= 0; path++, cp++) {
@@ -283,6 +291,7 @@ cd9660_open(const char *path, struct open_file *f)
struct iso_directory_record rec;
struct iso_directory_record *dp = NULL;
int rc, first, use_rrip, lenskip;
+ bool isdir = false;
/* First find the volume descriptor */
buf = malloc(buf_size = ISO_DEFAULT_BLOCK_SIZE);
@@ -372,7 +381,24 @@ cd9660_open(const char *path, struct open_file *f)
rec = *dp;
while (*path && *path != '/') /* look for next component */
path++;
- if (*path) path++; /* skip '/' */
+
+ if (*path) /* this component was directory */
+ isdir = true;
+
+ while (*path == '/')
+ path++; /* skip '/' */
+
+ if (*path) /* We do have next component. */
+ isdir = false;
+ }
+
+ /*
+ * if the path had trailing / but the path does point to file,
+ * report the error ENOTDIR.
+ */
+ if (isdir == true && (isonum_711(rec.flags) & 2) == 0) {
+ rc = ENOTDIR;
+ goto out;
}
/* allocate file system specific data structure */