0001-exp_main_sub.c-Use-PATH_MAX-for-path.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From 1407fcad6f1dac0a4efe8041660bf6139c1cd16a Mon Sep 17 00:00:00 2001
  2. From: Robert Yang <liezhi.yang@windriver.com>
  3. Date: Tue, 24 Sep 2019 13:40:10 +0800
  4. Subject: [PATCH] exp_main_sub.c: Use PATH_MAX for path
  5. If expect was built from a long path whose length > 200, then it couldn't run:
  6. $ expect -c 'puts yes'
  7. *** buffer overflow detected ***: expect terminated
  8. Aborted (core dumped)
  9. Use PATH_MAX to fix the problem.
  10. Upstream-Status: Pending [Upstream seems dead]
  11. Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
  12. ---
  13. exp_main_sub.c | 8 ++++++--
  14. 1 file changed, 6 insertions(+), 2 deletions(-)
  15. diff --git a/exp_main_sub.c b/exp_main_sub.c
  16. index fcfaa6e..bf6c4be 100644
  17. --- a/exp_main_sub.c
  18. +++ b/exp_main_sub.c
  19. @@ -48,6 +48,10 @@ char exp_version[] = PACKAGE_VERSION;
  20. #define NEED_TCL_MAJOR 7
  21. #define NEED_TCL_MINOR 5
  22. +#ifndef PATH_MAX
  23. +#define PATH_MAX 4096
  24. +#endif
  25. +
  26. char *exp_argv0 = "this program"; /* default program name */
  27. void (*exp_app_exit)() = 0;
  28. void (*exp_event_exit)() = 0;
  29. @@ -901,7 +905,7 @@ int sys_rc;
  30. int rc;
  31. if (sys_rc) {
  32. - char file[200];
  33. + char file[PATH_MAX];
  34. int fd;
  35. sprintf(file,"%s/expect.rc",SCRIPTDIR);
  36. @@ -917,7 +921,7 @@ int sys_rc;
  37. }
  38. }
  39. if (my_rc) {
  40. - char file[200];
  41. + char file[PATH_MAX];
  42. char *home;
  43. int fd;
  44. char *getenv();
  45. --
  46. 2.7.4