init_db: Terminate db creation on detecting invalid enumerator 39/310439/2
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 29 Apr 2024 04:12:51 +0000 (13:12 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 29 Apr 2024 04:26:12 +0000 (13:26 +0900)
To detect invalid modification on feature of enum type, the init_db
reports error by return code, let mic make use of it, aborting the
whole mic process.

Change-Id: Ic45e1e6949a6912203ce10bd85a8dcb8bb69b0b2
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
script/make_info_file.sh
src/init_db/system_info_db_init.c

index 5785294..3288469 100644 (file)
@@ -31,7 +31,10 @@ ID=$ID;
 EOF
 
        /usr/bin/system_info_init_db --input=/hal/etc/config/model-config.xml --output=/hal/etc/system_info_db
-
+       if [ $? -ne 0 ]; then
+               echo "Failed to generate system_info_db"
+               exit 1
+       fi
 else
        cat <<EOF > /etc/info.ini
 [Version]
@@ -47,6 +50,10 @@ ID=$ID;
 EOF
 
        /usr/bin/system_info_init_db
+       if [ $? -ne 0 ]; then
+               echo "Failed to generate system_info_db"
+               exit 1
+       fi
 
        # Create version info file for update
        if [ -e /usr/share/upgrade/record-version.sh ]; then
index 25ea4fa..d03600f 100644 (file)
@@ -93,7 +93,7 @@ static int db_set_value(const char *db_path,
                ret = system_info_util_get_enumerator_value(value, &__enumerator_value);
                if (ret < 0) {
                        _E("cannot find enumerator %s", value);
-                       return ret;
+                       exit(EXIT_FAILURE);
                }
 
                ret = snprintf(enumerator_value, sizeof(enumerator_value) - 1, "%d", __enumerator_value);