You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

  1. Subject: Bind to IPv4 localhost by default
  2. Origin: other, http://openocd.zylin.com/#/c/4331/2
  3. Last-Update: 2018-01-18
  4. From f8630b0b15e30dc6c51270006a4e075c79cf466a Mon Sep 17 00:00:00 2001
  5. From: Paul Fertser <fercerpav@gmail.com>
  6. Date: Sat, 13 Jan 2018 16:22:10 +0300
  7. Subject: [PATCH] server: bind to IPv4 localhost by default
  8. Since OpenOCD basically allows to perform arbitrary actions on behalf of
  9. the running user, it makes sense to restrict the exposure by default.
  10. If you need network connectivity and your environment is safe enough,
  11. use "bindto 0.0.0.0" to switch to the old behaviour.
  12. Change-Id: I4a4044b90d0ecb30118cea96fc92a7bcff0924e0
  13. Signed-off-by: Paul Fertser <fercerpav@gmail.com>
  14. ---
  15. diff --git a/doc/openocd.texi b/doc/openocd.texi
  16. index 7f5b72e..5c7f465 100644
  17. --- a/doc/openocd.texi
  18. +++ b/doc/openocd.texi
  19. @@ -7017,7 +7017,7 @@
  20. @deffn Command bindto [name]
  21. Specify address by name on which to listen for incoming TCP/IP connections.
  22. -By default, OpenOCD will listen on all available interfaces.
  23. +By default, OpenOCD will listen on the loopback interface only.
  24. @end deffn
  25. @anchor{targetstatehandling}
  26. diff --git a/src/server/server.c b/src/server/server.c
  27. index 1e52e97..ea1e898 100644
  28. --- a/src/server/server.c
  29. +++ b/src/server/server.c
  30. @@ -259,7 +259,7 @@
  31. c->sin.sin_family = AF_INET;
  32. if (bindto_name == NULL)
  33. - c->sin.sin_addr.s_addr = INADDR_ANY;
  34. + c->sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  35. else {
  36. hp = gethostbyname(bindto_name);
  37. if (hp == NULL) {