From 28de2a54ca1b4ee86c5f9b5655b3b0532f294bbf Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sat, 18 Jul 2020 18:00:55 +0200 Subject: SIM: Fix output of numbers >32767 when using EBD program mode A shift of an unsigned char is interpreted as signed char, which causes all bits above the shift result to become 1, if bit 7 of the char is 1. --- src/sim/sim.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sim/sim.c b/src/sim/sim.c index fba9417..f4d9d0f 100644 --- a/src/sim/sim.c +++ b/src/sim/sim.c @@ -203,20 +203,20 @@ void decode_ebdt(uint8_t *data, char *futln, char *sicherung, char *karten, char my_ultostr(futln++, data[0] & 0x1f, 1); if (*futln) futln++; - my_ultostr(futln, (data[1] << 8) | data[2], 5); + my_ultostr(futln, ((uint16_t)data[1] << 8) | (uint16_t)data[2], 5); } if (sicherung) - my_ultostr(sicherung, (data[3] << 8) | data[4], 1); + my_ultostr(sicherung, ((uint16_t)data[3] << 8) | (uint16_t)data[4], 1); if (karten) my_ultostr(karten, data[5] >> 5, 1); if (sonder) - my_ultostr(sonder, ((data[5] & 0x1f) << 8) | data[6], 1); + my_ultostr(sonder, ((uint16_t)(data[5] & 0x1f) << 8) | (uint16_t)data[6], 1); if (wartung) - my_ultostr(wartung, (data[7] << 8) | data[8], 1); + my_ultostr(wartung, ((uint16_t)data[7] << 8) | (uint16_t)data[8], 1); } /* get size of phone directory (including allocation map) */ -- cgit v1.2.3