From 928fe03b6e65bc5e2a9f762a993943ce9b033583 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Janosch=20Gr=C3=A4f?= Date: Sun, 7 Dec 2008 23:10:01 +0100 Subject: [PATCH] stdlibc/files: Check for valid path string; chdir: check for existing dir --- apps/lib/stdlibc/files.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/lib/stdlibc/files.c b/apps/lib/stdlibc/files.c index c622c87..c6816af 100644 --- a/apps/lib/stdlibc/files.c +++ b/apps/lib/stdlibc/files.c @@ -135,6 +135,7 @@ static struct fslist_item *mp_match(char *file,int parent) { * @return FSID */ static struct fslist_item *fsbypath(char *path,int parent) { + if (path==NULL || path[0]==0) return NULL; struct fslist_item *fs = mp_match(path,parent); if (fs==NULL) { fs = malloc(sizeof(struct fslist_item)); @@ -376,9 +377,9 @@ int chdir(const char *new) { new = getabsolutepath((char*)new); if (new==NULL) new = "/"; - /*DIR *dir = opendir(new); + DIR *dir = opendir(new); if (dir!=NULL) { - closedir(dir);*/ + closedir(dir); free(workdir.str); path_destroy(workdir.path); workdir.path = path_parse(new); @@ -387,8 +388,8 @@ int chdir(const char *new) { workdir.strlen = strlen(workdir.str); setenv("PATH",workdir.str,1); return 0; - //} - //else return -1; + } + else return -1; } /** -- 2.11.4.GIT