From 22d1db8c7ffac80fdb658dfb16a8eeea21d83cbd Mon Sep 17 00:00:00 2001 From: Nikolaj Schlej Date: Sat, 10 Sep 2022 14:20:49 +0200 Subject: [PATCH] Fix issues spotted by PVS-Studio and SonarCloud --- common/bstrlib/bstrwrap.cpp | 2 +- common/ffsparser.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/bstrlib/bstrwrap.cpp b/common/bstrlib/bstrwrap.cpp index 1f119ce..3f25514 100644 --- a/common/bstrlib/bstrwrap.cpp +++ b/common/bstrlib/bstrwrap.cpp @@ -1539,7 +1539,7 @@ std::istream& operator >> (std::istream& sin, CBString& b) { do { b.gets ((bNgetc) istreamGets, &sin, '\n'); if (b.slen > 0 && b.data[b.slen-1] == '\n') b.slen--; - } while (b.slen == 0 && !sin.eof ()); + } while (b.slen == 0 && !sin.eof() && !sin.fail()); return sin; } diff --git a/common/ffsparser.cpp b/common/ffsparser.cpp index c46657e..c4c8698 100644 --- a/common/ffsparser.cpp +++ b/common/ffsparser.cpp @@ -2886,6 +2886,7 @@ USTATUS FfsParser::parseDepexSectionBody(const UModelIndex & index) msg(usprintf("%s: DEPEX section ends with non-END opcode", __FUNCTION__), index); return U_SUCCESS; } + // No further parsing required return U_SUCCESS; case EFI_DEP_AFTER: if (body.size() != 2 * EFI_DEP_OPCODE_SIZE + sizeof(EFI_GUID)){ @@ -2899,6 +2900,7 @@ USTATUS FfsParser::parseDepexSectionBody(const UModelIndex & index) msg(usprintf("%s: DEPEX section ends with non-END opcode", __FUNCTION__), index); return U_SUCCESS; } + // No further parsing required return U_SUCCESS; case EFI_DEP_SOR: if (body.size() <= 2 * EFI_DEP_OPCODE_SIZE) { @@ -2967,8 +2969,8 @@ USTATUS FfsParser::parseDepexSectionBody(const UModelIndex & index) break; default: msg(usprintf("%s: unknown opcode %02Xh", __FUNCTION__, *current), index); + // No further parsing required return U_SUCCESS; - break; } }