aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2020-07-18 18:00:55 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2020-10-29 07:32:23 +0100
commit28de2a54ca1b4ee86c5f9b5655b3b0532f294bbf (patch)
treeb029e46b490a488d612590b990fa578ce1f5a75c
parentda54ca68ad953388ad0ae80aff36f925e48a54a9 (diff)
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.
-rw-r--r--src/sim/sim.c8
1 files 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) */