comparison common-algo.c @ 1753:7c0fcd19e492

Increase MAX_PROPOSED_ALGO to 50, warn if exceeded
author Matt Johnston <matt@ucc.asn.au>
date Fri, 23 Oct 2020 20:53:58 +0800
parents c2c0f43ff827
children 9efceb851bea
comparison
equal deleted inserted replaced
1752:36e77a51d5e4 1753:7c0fcd19e492
379 if (*ret_count == 0) { 379 if (*ret_count == 0) {
380 return; 380 return;
381 } 381 }
382 if (algolist_len > MAX_PROPOSED_ALGO*(MAX_NAME_LEN+1)) { 382 if (algolist_len > MAX_PROPOSED_ALGO*(MAX_NAME_LEN+1)) {
383 *ret_count = 0; 383 *ret_count = 0;
384 } 384 }
385 385
386 /* ret_list will contain a list of the strings parsed out. 386 /* ret_list will contain a list of the strings parsed out.
387 We will have at least one string (even if it's just "") */ 387 We will have at least one string (even if it's just "") */
388 ret_list[0] = algolist; 388 ret_list[0] = algolist;
389 *ret_count = 1; 389 *ret_count = 1;
390 for (i = 0; i < algolist_len; i++) { 390 for (i = 0; i < algolist_len; i++) {
391 if (algolist[i] == '\0') { 391 if (algolist[i] == '\0') {
392 /* someone is trying something strange */ 392 /* someone is trying something strange */
393 *ret_count = 0; 393 *ret_count = 0;
394 return; 394 return;
395 } 395 }
396 396
397 if (algolist[i] == ',') { 397 if (algolist[i] == ',') {
398 if (*ret_count >= max_count) { 398 if (*ret_count >= max_count) {
399 /* Too many */ 399 dropbear_log(LOG_WARNING, "Too many remote algorithms");
400 *ret_count = 0; 400 *ret_count = 0;
401 return; 401 return;
402 } 402 }
403 algolist[i] = '\0'; 403 algolist[i] = '\0';
404 ret_list[*ret_count] = &algolist[i+1]; 404 ret_list[*ret_count] = &algolist[i+1];