PR26415 UBSAN: vms-misc.c:636 left shift cannot be represented

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.
This commit is contained in:
Alan Modra 2020-08-26 11:26:35 +09:30
parent a68aba2da7
commit b4e125d935
2 changed files with 7 additions and 2 deletions

View 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.

View 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;