[Libsysio-commit] HEAD: libsysio/drivers/incore fs_incore.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2007-03-14 19:14:39
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5568/drivers/incore Modified Files: fs_incore.c Log Message: Fixed a serious bug reported by Wally Wang at Cray (SPR #731860): The incore driver will match a directory entry containing a name equal to or longer than the one we are searching for. Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -w -b -B -p -r1.26 -r1.27 --- fs_incore.c 9 Mar 2007 23:15:37 -0000 1.26 +++ fs_incore.c 14 Mar 2007 19:14:33 -0000 1.27 @@ -778,18 +778,29 @@ incore_directory_probe(void *data, static struct intnl_dirent * incore_directory_match(struct intnl_dirent *de, - size_t reclen __IS_UNUSED, + size_t reclen, struct lookup_data *ld) { + size_t len; #if defined(BSD) || defined(REDSTORM) if (IFTODT(de->d_type) == DT_WHT) return NULL; #endif - if ( #ifdef _DIRENT_HAVE_D_NAMLEN - ld->name->len == de->d_namlen && + len = de->d_namlen; +#else + { + const char *cp, *end; + + cp = de->d_name; + end = (const char *)de + reclen; + while (cp < end && *cp != '\0') + cp++; + len = cp - de->d_name; + } #endif + if (ld->name->len == len && strncmp(de->d_name, ld->name->name, ld->name->len) == 0) return de; ld->de = de; |