1
0

900-fix_cve2017-16544.patch 543 B

12345678910111213141516171819202122
  1. --- a/libbb/lineedit.c
  2. +++ b/libbb/lineedit.c
  3. @@ -632,6 +632,19 @@ static void free_tab_completion_data(voi
  4. static void add_match(char *matched)
  5. {
  6. + unsigned char *p = (unsigned char*)matched;
  7. + while (*p) {
  8. + /* ESC attack fix: drop any string with control chars */
  9. + if (*p < ' '
  10. + || (!ENABLE_UNICODE_SUPPORT && *p >= 0x7f)
  11. + || (ENABLE_UNICODE_SUPPORT && *p == 0x7f)
  12. + ) {
  13. + free(matched);
  14. + return;
  15. + }
  16. + p++;
  17. + }
  18. +
  19. matches = xrealloc_vector(matches, 4, num_matches);
  20. matches[num_matches] = matched;
  21. num_matches++;