PR26415 UBSAN: vms-misc.c:636 left shift cannot be represented
authorAlan Modra <amodra@gmail.com>
Wed, 26 Aug 2020 01:56:35 +0000 (11:26 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 26 Aug 2020 13:53:44 +0000 (23:23 +0930)
An unsigned short value is promoted to int, thus triggering UB on a
left shift of a positive value that results in a negative int.

PR 26415
* vms-misc.c (vms_time_t_to_vms_time): Don't use unsigned short vars.

bfd/ChangeLog
bfd/vms-misc.c

index 616b22f1600ea7b349dc81254a8c05af655fd63f..fe440e89c6be7fe850214d88b1f7bf8ce3a5b013 100644 (file)
@@ -1,3 +1,8 @@
+2020-08-26  Alan Modra  <amodra@gmail.com>
+
+       PR 26415
+       * vms-misc.c (vms_time_t_to_vms_time): Don't use unsigned short vars.
+
 2020-08-26  David Faust  <david.faust@oracle.com>
 
        * archures.c (bfd_mach_xbpf): Define.
index d040c79de16ce761e5705eefe951d97160657fd6..0826456ef0ff910552a98c3566be86eeda82e143 100644 (file)
@@ -592,8 +592,8 @@ vms_time_to_time_t (unsigned int hi, unsigned int lo)
 void
 vms_time_t_to_vms_time (time_t ut, unsigned int *hi, unsigned int *lo)
 {
-  unsigned short val[4];
-  unsigned short tmp[4];
+  unsigned int val[4];
+  unsigned int tmp[4];
   unsigned int carry;
   int i;