From 8769d7ac10ee9a0a052cbcac7d83c8d806e47dcc Mon Sep 17 00:00:00 2001
From: Andrea Zoli <athlonz900@gmail.com>
Date: Thu, 19 Feb 2015 22:46:45 +0100
Subject: [PATCH] Throw exception on chdir error.

---
 src/ConfigurationFile.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/ConfigurationFile.cpp b/src/ConfigurationFile.cpp
index 6ee6872..dd51659 100644
--- a/src/ConfigurationFile.cpp
+++ b/src/ConfigurationFile.cpp
@@ -21,6 +21,7 @@
 #include <unistd.h>
 #include <string>
 #include <algorithm>
+#include <sstream>
 
 using namespace PacketLib;
 
@@ -54,7 +55,13 @@ bool ConfigurationFile::open(char** parameters) throw(PacketExceptionIO*)
 void ConfigurationFile::close() throw(PacketExceptionIO*)
 {
     InputTextFile::close();
-    chdir(currentpwd);
+	int retval = chdir(currentpwd);
+	if(retval == -1)
+	{
+		std::stringstream ss;
+		ss << "Invalid chdir on '" << currentpwd << "'" << std::endl;
+		throw PacketExceptionIO(ss.str().c_str());
+	}
 }
 
 
-- 
GitLab