File lsvpd.bug-1072079_std_io_base_failure_workaround.patch of Package lsvpd

commit c36b20b7dc2e787f7285e459851df1a74368e8e3
Author: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Date:   Wed Sep 20 16:52:35 2017 +0530

    lsvpd: Add workaround for std::ios_base::failure' issue
    
    Recently on P9 we started seeing below error.
    
    #vpdupdate
    terminate called after throwing an instance of 'std::ios_base::failure'
    what():  basic_filebuf::underflow error reading the file
    Aborted (core dumped)
    
    It turns out that we needed c++ fix. Lets add workaround so that we
    don't crash.
    
    Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
    Reviewed-by: Ankit Kumar <ankit@linux.vnet.ibm.com>

diff --git a/src/internal/sys_interface/icollector.cpp b/src/internal/sys_interface/icollector.cpp
index 0d48c93..d6407d9 100644
--- a/src/internal/sys_interface/icollector.cpp
+++ b/src/internal/sys_interface/icollector.cpp
@@ -104,6 +104,17 @@ namespace lsvpd
 	 */
 	string ICollector::getBinaryData( const string& path )
 	{
+		struct stat sbuf;
+
+		/*
+		 * Check file existence and size before calling ifstream
+		 *
+		 * Workaround for libstdc++ issue.
+		 * https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=250545
+		 */
+		if ((stat(path.c_str(), &sbuf) != 0) || (sbuf.st_size == 0))
+			return "";
+
 		ifstream fi(path.c_str(), ios::binary);
 		string str;
 
openSUSE Build Service is sponsored by