From: Ondrej Kozina Date: Wed, 30 Jan 2013 17:34:36 +0000 (+0100) Subject: - fix condition on open() check X-Git-Tag: v0.1.3~18^2~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c174567648efa1eda53d805f45cbb27475afe90;p=thirdparty%2Fsnapper.git - fix condition on open() check - close fd on error - catch XAttributesException() during container construction --- diff --git a/snapper/Compare.cc b/snapper/Compare.cc index abf3fed2..c8cc5a03 100644 --- a/snapper/Compare.cc +++ b/snapper/Compare.cc @@ -475,15 +475,27 @@ namespace snapper } int fd2 = file2.open(O_RDONLY | O_NOFOLLOW | O_NOATIME | O_CLOEXEC); - if (fd1 < 0) + if (fd2 < 0) { y2err("open failed path:" << file2.fullname() << " errno:" << errno); + close(fd1); throw IOErrorException(); } - XAttributes xa(fd1), xb(fd2); + bool retval; + + try + { + XAttributes xa(fd1), xb(fd2); + retval = (xa == xb); + } + catch (XAttributesException xae) + { + retval = false; + } close(fd1); close(fd2); - return (xa == xb); + + return retval; } }