1
0
Fork 0
forked from len0rd/rockbox

strtok:ing a copy of the parameter instead

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@687 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-05-24 09:57:33 +00:00
parent 40c6129c91
commit a7b8b00fd4

View file

@ -29,7 +29,9 @@ static bool busy=false;
DIR* opendir(char* name) DIR* opendir(char* name)
{ {
char namecopy[256];
char* part; char* part;
char* end;
struct fat_direntry entry; struct fat_direntry entry;
struct fat_dir* dir = &(thedir.fatdir); struct fat_dir* dir = &(thedir.fatdir);
@ -48,9 +50,11 @@ DIR* opendir(char* name)
return NULL; return NULL;
} }
/* fixme: strtok() is not thread safe, and fat_getnext() calls yield() */ strncpy(namecopy,name,sizeof(namecopy));
for ( part = strtok(name, "/"); part; namecopy[sizeof(namecopy)-1] = 0;
part = strtok(NULL, "/")) {
for ( part = strtok_r(namecopy, "/", &end); part;
part = strtok_r(NULL, "/", &end)) {
int partlen = strlen(part); int partlen = strlen(part);
/* scan dir for name */ /* scan dir for name */
while (1) { while (1) {