[spice PATCH v2 2/6] image_encoders: check shared_dict before accessing it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In both image_encoders_restore_glz_dictionary() and
image_encoders_get_glz_dictionary() shared-dict may
be NULL if size is too large, and the server gets
size from the network.

Both functions end up calling glz_enc_dictionary_create()
that calls glz_dictionary_window_create() where size is
checked.

Found by coverity.

Signed-off-by: Uri Lublin <uril@xxxxxxxxxx>
---
 server/image-encoders.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/server/image-encoders.c b/server/image-encoders.c
index 3a73e0c..0d57260 100644
--- a/server/image-encoders.c
+++ b/server/image-encoders.c
@@ -746,7 +746,9 @@ gboolean image_encoders_get_glz_dictionary(ImageEncoders *enc,
         shared_dict->refs++;
     } else {
         shared_dict = create_glz_dictionary(enc, client, id, window_size);
-        glz_dictionary_list = g_list_prepend(glz_dictionary_list, shared_dict);
+        if (shared_dict != NULL) {
+            glz_dictionary_list = g_list_prepend(glz_dictionary_list, shared_dict);
+        }
     }
 
     pthread_mutex_unlock(&glz_dictionary_list_lock);
@@ -782,7 +784,9 @@ gboolean image_encoders_restore_glz_dictionary(ImageEncoders *enc,
         shared_dict->refs++;
     } else {
         shared_dict = restore_glz_dictionary(enc, client, id, restore_data);
-        glz_dictionary_list = g_list_prepend(glz_dictionary_list, shared_dict);
+        if(shared_dict != NULL) {
+            glz_dictionary_list = g_list_prepend(glz_dictionary_list, shared_dict);
+        }
     }
 
     pthread_mutex_unlock(&glz_dictionary_list_lock);
-- 
2.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]