Fix coverity issue 13/318713/1 accepted/tizen_unified accepted/tizen_unified_x accepted/tizen_unified_x_asan tizen accepted/tizen/unified/20250124.043540 accepted/tizen/unified/x/20250124.061121 accepted/tizen/unified/x/asan/20250211.003150
authorMateusz Moscicki <m.moscicki2@samsung.com>
Wed, 22 Jan 2025 12:04:50 +0000 (13:04 +0100)
committerMateusz Moscicki <m.moscicki2@samsung.com>
Wed, 22 Jan 2025 12:22:39 +0000 (13:22 +0100)
Change-Id: I6dc494593e61845d208b7f7af1a5102038aad3fe

src/bootmode-recovery/system-recovery.h.in
src/bow-restore/bow-restore.cpp

index ac9ef6e914be94425664b2d9665601237556d78b..a3cd8a47ef809c5ca76da48847ab8e09503573a7 100644 (file)
@@ -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;
 };
 
index 9f694cf9aef4dd0166ab2e71b491f8cba98c1588..b84241039a464001a00327fc8180c2fbcfca9f2e 100644 (file)
@@ -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;
 }