103-CVE-2017-1000100.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. From 358b2b131ad6c095696f20dcfa62b8305263f898 Mon Sep 17 00:00:00 2001
  2. From: Daniel Stenberg <daniel@haxx.se>
  3. Date: Tue, 1 Aug 2017 17:16:46 +0200
  4. Subject: [PATCH] tftp: reject file name lengths that don't fit
  5. ... and thereby avoid telling send() to send off more bytes than the
  6. size of the buffer!
  7. CVE-2017-1000100
  8. Bug: https://curl.haxx.se/docs/adv_20170809B.html
  9. Reported-by: Even Rouault
  10. Credit to OSS-Fuzz for the discovery
  11. ---
  12. lib/tftp.c | 7 ++++++-
  13. 1 file changed, 6 insertions(+), 1 deletion(-)
  14. --- a/lib/tftp.c
  15. +++ b/lib/tftp.c
  16. @@ -5,7 +5,7 @@
  17. * | (__| |_| | _ <| |___
  18. * \___|\___/|_| \_\_____|
  19. *
  20. - * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
  21. + * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
  22. *
  23. * This software is licensed as described in the file COPYING, which
  24. * you should have received as part of this distribution. The terms
  25. @@ -490,6 +490,11 @@ static CURLcode tftp_send_first(tftp_sta
  26. if(result)
  27. return result;
  28. + if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
  29. + failf(data, "TFTP file name too long\n");
  30. + return CURLE_TFTP_ILLEGAL; /* too long file name field */
  31. + }
  32. +
  33. snprintf((char *)state->spacket.data+2,
  34. state->blksize,
  35. "%s%c%s%c", filename, '\0', mode, '\0');