diff options
author | Liu Aleaxander <Aleaxander@gmail.com> | 2009-05-24 16:57:24 +0800 |
---|---|---|
committer | Liu Aleaxander <Aleaxander@gmail.com> | 2009-05-24 16:57:24 +0800 |
commit | 0bf5aa38d3b2574e5963c7e5f3843d09390b155b (patch) | |
tree | 79fecbe07cd5ce710eed3d4e78c08243f37f521d /isolinux.c | |
parent | 60ec7dc442d580970c5e72bb972fb5f770160cf4 (diff) | |
download | devel-0bf5aa38d3b2574e5963c7e5f3843d09390b155b.tar.gz devel-0bf5aa38d3b2574e5963c7e5f3843d09390b155b.tar.xz devel-0bf5aa38d3b2574e5963c7e5f3843d09390b155b.zip |
fixed some bugs of dir searchingisolinux
Diffstat (limited to 'isolinux.c')
-rw-r--r-- | isolinux.c | 51 |
1 files changed, 37 insertions, 14 deletions
@@ -225,41 +225,49 @@ void mangle_name(char *dst, char *src) * compare the names si and di and report if they are * equal from an ISO 9600 perspective. * - * @param: si, the name from the file system. - * @param: cx, the length of si - * @param: di, is expected to end with a null + * @param: de_name, the name from the file system. + * @param: len, the length of de_name, and will return the real name of the de_name + * ';' and other terminates excluded. + * @param: file_name, the name we want to check, is expected to end with a null * * @return: 1 on match, or 0. * */ -int iso_compare_names(char *de_name, __u32 len, char *file_name) +int iso_compare_names(char *de_name, __u32 *len, char *file_name) { char *p = ISOFileName; char c1, c2; - int i = len; + int i = 0; - while ( i && *de_name && (*de_name != ';') && (p < ISOFileNameEnd - 1) ) { + while ( (i < *len) && *de_name && (*de_name != ';') && (p < ISOFileNameEnd - 1) ) { *p++ = *de_name++; - i --; + i++; } + /* Remove terminal dots */ while ( *(p-1) == '.' ) { + if ( *len <= 2 ) + break; + if ( p <= ISOFileName ) break; p --; + i--; } - *p = '\0'; + /* return the 'real' length of de_name */ + *len = i; p = ISOFileName; - while ( len ) { + /* i is the 'real' name length of file_name */ + while ( i ) { c1 = *p++; c2 = *file_name++; @@ -273,7 +281,7 @@ int iso_compare_names(char *de_name, __u32 len, char *file_name) c2 |= 0x20; /* convert to lower case */ if ( c1 != c2 ) return 0; - len --; + i --; } return 1; @@ -357,6 +365,8 @@ int do_search_dir(struct dir_t *dir, char *name, void **res) de = (struct iso_dir_entry *)trackbuf; while ( file_pos < dir->dir_len ) { + int found = 0; + if ( (char *)de >= (char *)(trackbuf + trackbufsize) ) { if ( !have_more ) return 0; @@ -399,14 +409,28 @@ int do_search_dir(struct dir_t *dir, char *name, void **res) de_name_len = de->name_len; de_name = (char *)((void *)de + 0x21); - if ( iso_compare_names(de_name, de_name_len, name) ) - break; /* we found it */ + + + if ( (de_name_len == 1) && (*de_name == 0) ) { + found = iso_compare_names(".", &de_name_len, name); + + } else if ( (de_name_len == 1) && (*de_name == 1) ) { + de_name_len == 2; + found = iso_compare_names("..", &de_name_len, name); + + } else + found = iso_compare_names(de_name, &de_name_len, name); + + if (found) + break; file_pos += de_len; } if ( *(name+de_name_len) && (*(name+de_name_len) != '/' ) ) { + printf("Something wrong happened during searching file %s\n", name); + *res = NULL; return 0; } @@ -466,8 +490,7 @@ struct open_file_t *searchdir(char *filename) void *res; int ret; - int flag = 0; - + dir = &CurrentDir; if ( *filename == '/' ) { |