When the number of records for a given user is 0, there is a dummy byte
at the end of the user memory block which has to be consumed as well,
otherwise the while loop never ends.
The bug was found out by Cornelis Broeders <cornelis.broeders@web.de>
440601 1319 0 114 063 066
100101 1400 0 114 070 071
130312 1145 0 121 080 072
440601 1319 0 114 063 066
100101 1400 0 114 070 071
130312 1145 0 121 080 072
+
+When the number of records is 0, there is a dummy byte at the end of the user
+memory block, e.g.:
+
+ M1001M20115110321300134097083
+
+The structure is:
+
+ M
+ 1
+ 00
+ 1 # dummy byte, present only when the previous field is 00
+ M
+ 2
+ 01
+ 151103 2130 0 134 097 083
/* user_id and num_records take 3 bytes */
i += 3;
/* user_id and num_records take 3 bytes */
i += 3;
+ /*
+ * when there are no records, there is a dummy byte
+ * which has to be consumed
+ */
+ if (num_records == 0)
+ i += 1;
+
for (j = 0; j < num_records; j++) {
ret = extract_datetime(buffer + i, &d);
if (ret < 0)
for (j = 0; j < num_records; j++) {
ret = extract_datetime(buffer + i, &d);
if (ret < 0)