Fixed SSID input validation

This commit is contained in:
Jonathan karras 2015-08-22 15:59:15 -06:00
parent 373e4d8274
commit 469740c86f
1 changed files with 29 additions and 25 deletions

View File

@ -417,36 +417,40 @@ void ss_serialCallback(void *_buffer, size_t length, AX25Ctx *ctx) {
} else if (buffer[0] == 's' && length > 2) { } else if (buffer[0] == 's' && length > 2) {
buffer++; length--; buffer++; length--;
if (buffer[0] == 'c') { if (buffer[0] == 'c') {
if (length > 2 && buffer[2] > 48 && buffer[2] < 58) { if (length > 2 && buffer[2] > 48 && buffer[2] < 58 && buffer[1] > 48) {
CALL_SSID = 10+buffer[2]-48; CALL_SSID = 10+buffer[2]-48;
} else { } else
if ( buffer[1] > 48 && buffer[1] < 58) {
CALL_SSID = buffer[1]-48; CALL_SSID = buffer[1]-48;
} }
if (VERBOSE) printf_P(PSTR("Callsign: %.6s-%d\n"), CALL, CALL_SSID); if (VERBOSE) printf_P(PSTR("Callsign: %.6s-%d\n"), CALL, CALL_SSID);
if (!VERBOSE && !SILENT) printf_P(PSTR("1\n")); if (!VERBOSE && !SILENT) printf_P(PSTR("1\n"));
} }
if (buffer[0] == 'd') { if (buffer[0] == 'd') {
if (length > 2 && buffer[2] > 48 && buffer[2] < 58) { if (length > 2 && buffer[2] > 48 && buffer[2] < 58 && buffer[1] > 48) {
DST_SSID = 10+buffer[2]-48; DST_SSID = 10+buffer[2]-48;
} else { } else
if ( buffer[1] > 48 && buffer[1] < 58) {
DST_SSID = buffer[1]-48; DST_SSID = buffer[1]-48;
} }
if (VERBOSE) printf_P(PSTR("Destination: %.6s-%d\n"), DST, DST_SSID); if (VERBOSE) printf_P(PSTR("Destination: %.6s-%d\n"), DST, DST_SSID);
if (!VERBOSE && !SILENT) printf_P(PSTR("1\n")); if (!VERBOSE && !SILENT) printf_P(PSTR("1\n"));
} }
if (buffer[0] == '1' && buffer[2] > 48 && buffer[2] < 58) { if (buffer[0] == '1' ) {
if (length > 2) { if (length > 2 && buffer[2] > 48 && buffer[2] < 58 && buffer[1] > 48) {
PATH1_SSID = 10+buffer[2]-48; PATH1_SSID = 10+buffer[2]-48;
} else { } else
if ( buffer[1] > 48 && buffer[1] < 58) {
PATH1_SSID = buffer[1]-48; PATH1_SSID = buffer[1]-48;
} }
if (VERBOSE) printf_P(PSTR("Path1: %.6s-%d\n"), PATH1, PATH1_SSID); if (VERBOSE) printf_P(PSTR("Path1: %.6s-%d\n"), PATH1, PATH1_SSID);
if (!VERBOSE && !SILENT) printf_P(PSTR("1\n")); if (!VERBOSE && !SILENT) printf_P(PSTR("1\n"));
} }
if (buffer[0] == '2' && buffer[2] > 48 && buffer[2] < 58) { if (buffer[0] == '2' ) {
if (length > 2) { if (length > 2 && buffer[2] > 48 && buffer[2] < 58 && buffer[1] > 48) {
PATH2_SSID = 10+buffer[2]-48; PATH2_SSID = 10+buffer[2]-48;
} else { } else
if (buffer[2] > 48 && buffer[2] < 58) {
PATH2_SSID = buffer[1]-48; PATH2_SSID = buffer[1]-48;
} }
if (VERBOSE) printf_P(PSTR("Path2: %.6s-%d\n"), PATH2, PATH2_SSID); if (VERBOSE) printf_P(PSTR("Path2: %.6s-%d\n"), PATH2, PATH2_SSID);