kbx: Avoid undefined behavior.
authorJustus Winter <justus@g10code.com>
Mon, 7 Mar 2016 13:25:38 +0000 (14:25 +0100)
committerJustus Winter <justus@g10code.com>
Mon, 7 Mar 2016 13:38:11 +0000 (14:38 +0100)
* kbx/keybox-file.c (_keybox_read_blob2): Cast to unsigned int before
shifting.

Signed-off-by: Justus Winter <justus@g10code.com>
kbx/keybox-file.c

index eaf7565..59dfe0c 100644 (file)
@@ -77,7 +77,7 @@ _keybox_read_blob2 (KEYBOXBLOB *r_blob, FILE *fp, int *skipped_deleted)
       return gpg_error_from_syserror ();
     }
 
-  imagelen = (c1 << 24) | (c2 << 16) | (c3 << 8 ) | c4;
+  imagelen = ((unsigned int) c1 << 24) | (c2 << 16) | (c3 << 8 ) | c4;
   if (imagelen < 5)
     return gpg_error (GPG_ERR_TOO_SHORT);