From: Mateusz Moscicki Date: Wed, 22 Jan 2025 12:04:50 +0000 (+0100) Subject: Fix coverity issue X-Git-Tag: accepted/tizen/unified/20250124.043540^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_unified;p=platform%2Fcore%2Fsystem%2Finitrd-recovery.git Fix coverity issue Change-Id: I6dc494593e61845d208b7f7af1a5102038aad3fe --- diff --git a/src/bootmode-recovery/system-recovery.h.in b/src/bootmode-recovery/system-recovery.h.in index ac9ef6e..a3cd8a4 100644 --- a/src/bootmode-recovery/system-recovery.h.in +++ b/src/bootmode-recovery/system-recovery.h.in @@ -34,9 +34,9 @@ do { \ #define IMAGE_FIELD_LENGTH_STR STRINGIFY(FIELD_LENGTH) struct image { - char label[FIELD_LENGTH]; - char basename[FIELD_LENGTH]; - char devpath[FIELD_LENGTH]; + char label[FIELD_LENGTH+1]; + char basename[FIELD_LENGTH+1]; + char devpath[FIELD_LENGTH+1]; struct image *next; }; diff --git a/src/bow-restore/bow-restore.cpp b/src/bow-restore/bow-restore.cpp index 9f694cf..b842410 100644 --- a/src/bow-restore/bow-restore.cpp +++ b/src/bow-restore/bow-restore.cpp @@ -432,13 +432,18 @@ int main(int argc, char *argv[]) { } std::string blockDevice(argv[1]); - Status status = cp_restoreCheckpoint(blockDevice, 0); - if (!status.isOk()) { - LOG(ERROR) << "bow-restore error: " << status.message() << "\n"; + try { + Status status = cp_restoreCheckpoint(blockDevice, 0); + if (!status.isOk()) { + LOG(ERROR) << "bow-restore error: " << status.message() << "\n"; + return EXIT_FAILURE; + } + if (status.hasMessage()) { + LOG(INFO) << "bow-restore info: " << status.message() << "\n"; + } + } catch (...) { + LOG(ERROR) << "bow-restore error" << "\n"; return EXIT_FAILURE; } - if (status.hasMessage()) { - LOG(INFO) << "bow-restore info: " << status.message() << "\n"; - } return EXIT_SUCCESS; }