From: Matthew Dillon Date: Tue, 2 Nov 2010 20:58:15 +0000 (-0700) Subject: libstand - Fix CD9660 name matching code X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/3a8855e99c465d7a950ac3dd89ce9bf407c0cf97 libstand - Fix CD9660 name matching code * The code inherited from FBsd did not properly deal with matching path elements after a '.'. For example "kernel.FUBAR_XYZ" would match "kernel.FUBAR" on the CD. * Fixed. --- diff --git a/lib/libstand/cd9660.c b/lib/libstand/cd9660.c index 77ceb2c590..ed5cbc7ed0 100644 --- a/lib/libstand/cd9660.c +++ b/lib/libstand/cd9660.c @@ -261,18 +261,25 @@ dirmatch(struct open_file *f, const char *path, struct iso_directory_record *dp, } if (*path && *path != '/') return 0; + /* * Allow stripping of trailing dots and the version number. + * * Note that this will find the first instead of the last version - * of a file. + * of a file unless explicitly specified. + * + * For any inexact matches we ignore everything after and including + * the semicolon in the directory entry name, assuming it is a + * version number whether it is or not. */ - if (i >= 0 && (*cp == ';' || *cp == '.')) { - /* This is to prevent matching of numeric extensions */ - if (*cp == '.' && cp[1] != ';') - return 0; - while (--i >= 0) - if (*++cp != ';' && (*cp < '0' || *cp > '9')) - return 0; + if (i >= 0) { + if (cp[0] == ';') + return 1; /* ignore version */ + if (cp[0] == '.' && i == 0) + return 1; /* ignore trailing dot */ + if (cp[0] == '.' && i > 0 && cp[1] == ';') + return 1; /* ignore trailing dot w/ version */ + return 0; /* else mismatch */ } return 1; }