From: Sansar Choinyambuu Date: Fri, 16 Sep 2011 09:17:32 +0000 (+0200) Subject: Fixed bug at checking error code from file stat X-Git-Tag: 4.6.2~370 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9032e61b88dccd145f34c9a98f3933f3073dd49d;p=thirdparty%2Fstrongswan.git Fixed bug at checking error code from file stat --- diff --git a/src/libpts/pts/pts.c b/src/libpts/pts/pts.c index 3a8c464fe4..d46196974b 100644 --- a/src/libpts/pts/pts.c +++ b/src/libpts/pts/pts.c @@ -273,29 +273,28 @@ static char* get_filename(char *pathname) METHOD(pts_t, is_path_valid, bool, private_pts_t *this, char *path, pts_error_code_t *error_code) { - int error; struct stat st; - + *error_code = 0; - error = stat(path, &st); - if (error == 0) + + if (!stat(path, &st)) { return TRUE; } - else if (error == ENOENT || error == ENOTDIR) + else if (errno == ENOENT || errno == ENOTDIR) { DBG1(DBG_PTS, "file/directory does not exist %s", path); *error_code = TCG_PTS_FILE_NOT_FOUND; } - else if (error == EFAULT) + else if (errno == EFAULT) { DBG1(DBG_PTS, "bad address %s", path); *error_code = TCG_PTS_INVALID_PATH; } else { - DBG1(DBG_PTS, "error: %s occurred while validating path: %s", - strerror(error), path); + DBG1(DBG_PTS, "error: %s occured while validating path: %s", + strerror(errno), path); return FALSE; }