Fix null dereference 30/168330/3
authorSeungha Son <seungha.son@samsung.com>
Fri, 26 Jan 2018 01:07:54 +0000 (10:07 +0900)
committerSeungha Son <seungha.son@samsung.com>
Mon, 29 Jan 2018 08:06:32 +0000 (17:06 +0900)
 If app_id is null and length of 'app_id' is 0 and
 type is 'NOTIFICATION_TYPE_NONE', query_where variable
 is dereference null.

Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: I414e27fdd0731104cae1ffea85e02ee12a191a45

src/notification_noti.c

index 9d964ae..a799fb1 100755 (executable)
@@ -1224,15 +1224,15 @@ EXPORT_API int notification_noti_delete_all(notification_type_e type,
        }
 
        if (app_id == NULL || strlen(app_id) == 0) {
-               if (type != NOTIFICATION_TYPE_NONE) {
-                       query_where = sqlite3_mprintf("WHERE type = %d "
-                                               "AND uid = %d", type, uid);
-                       if (query_where == NULL) {
-                               /* LCOV_EXCL_START */
-                               ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
-                               goto err;
-                               /* LCOV_EXCL_STOP */
-                       }
+               if (type == NOTIFICATION_TYPE_NONE)
+                       query_where = sqlite3_mprintf("WHERE uid = %d", uid);
+               else
+                       query_where = sqlite3_mprintf("WHERE type = %d AND uid = %d", type, uid);
+               if (query_where == NULL) {
+                       /* LCOV_EXCL_START */
+                       ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+                       goto err;
+                       /* LCOV_EXCL_STOP */
                }
        } else {
                if (type == NOTIFICATION_TYPE_NONE)