Terminal program for MailStation devices
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

mslib: use a stack buffer for temporary storage in uitoa

Apparently this implementation requires that "string" be at least
NUMBER_OF_DIGITS in length because it starts writing at
string[NUMBER_OF_DIGITS] and works backwards.

Since not all callers are passing a buffer that big, use a temporary
buffer for writing out digits before writing them left-to-right into
string.

+6 -5
+5 -4
mslib.c
··· 24 24 void 25 25 uitoa(unsigned int value, char *string, int radix) 26 26 { 27 + unsigned char t[NUMBER_OF_DIGITS + 1]; 27 28 unsigned char index, i; 28 29 29 30 index = NUMBER_OF_DIGITS; 30 31 i = 0; 31 32 32 33 do { 33 - string[--index] = '0' + (value % radix); 34 - if (string[index] > '9') 35 - string[index] += 'A' - ':'; 34 + t[--index] = '0' + (value % radix); 35 + if (t[index] > '9') 36 + t[index] += 'A' - ':'; 36 37 value /= radix; 37 38 } while (value != 0); 38 39 39 40 do { 40 - string[i++] = string[index++]; 41 + string[i++] = t[index++]; 41 42 } while (index < NUMBER_OF_DIGITS); 42 43 43 44 string[i] = '\0';
+1 -1
msterm.c
··· 101 101 /* Select modulation - V.34, automode, min_rate */ 102 102 obuf_queue("+MS=11,1,300,"); 103 103 /* max_rate */ 104 - sprintf(ms, "%u", setting_modem_speed); 104 + itoa(setting_modem_speed, ms, 10); 105 105 obuf_queue(ms); 106 106 /* Turn speaker off */ 107 107 obuf_queue("M0");