0031-patchlevel-31.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From http://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-031
  2. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
  3. BASH PATCH REPORT
  4. =================
  5. Bash-Release: 4.3
  6. Patch-ID: bash43-031
  7. Bug-Reported-by: lolilolicon <lolilolicon@gmail.com>
  8. Bug-Reference-ID: <CAMtVo_Nz=32Oq=zWTb6=+8gUNXOo2rRvud1W4oPnA-cgVk_ZqQ@mail.gmail.com>
  9. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2014-08/msg00139.html
  10. Bug-Description:
  11. The new nameref assignment functionality introduced in bash-4.3 did not perform
  12. enough validation on the variable value and would create variables with
  13. invalid names.
  14. Patch (apply with `patch -p0'):
  15. *** a/bash-4.3-patched/subst.h 2014-01-11 21:02:27.000000000 -0500
  16. --- b/subst.h 2014-09-01 12:16:56.000000000 -0400
  17. ***************
  18. *** 48,51 ****
  19. --- 48,52 ----
  20. #define ASS_MKGLOBAL 0x0008 /* force global assignment */
  21. #define ASS_NAMEREF 0x0010 /* assigning to nameref variable */
  22. + #define ASS_FROMREF 0x0020 /* assigning from value of nameref variable */
  23. /* Flags for the string extraction functions. */
  24. *** a/bash-4.3-patched/variables.c 2014-05-15 08:26:50.000000000 -0400
  25. --- b/variables.c 2014-09-01 14:37:44.000000000 -0400
  26. ***************
  27. *** 2504,2511 ****
  28. int hflags, aflags;
  29. {
  30. ! char *newval;
  31. SHELL_VAR *entry;
  32. entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table);
  33. /* Follow the nameref chain here if this is the global variables table */
  34. if (entry && nameref_p (entry) && (invisible_p (entry) == 0) && table == global_variables->table)
  35. --- 2566,2590 ----
  36. int hflags, aflags;
  37. {
  38. ! char *newname, *newval;
  39. SHELL_VAR *entry;
  40. + #if defined (ARRAY_VARS)
  41. + arrayind_t ind;
  42. + char *subp;
  43. + int sublen;
  44. + #endif
  45. + newname = 0;
  46. + #if defined (ARRAY_VARS)
  47. + if ((aflags & ASS_FROMREF) && (hflags & HASH_NOSRCH) == 0 && valid_array_reference (name))
  48. + {
  49. + newname = array_variable_name (name, &subp, &sublen);
  50. + if (newname == 0)
  51. + return (SHELL_VAR *)NULL; /* XXX */
  52. + entry = hash_lookup (newname, table);
  53. + }
  54. + else
  55. + #endif
  56. entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table);
  57. +
  58. /* Follow the nameref chain here if this is the global variables table */
  59. if (entry && nameref_p (entry) && (invisible_p (entry) == 0) && table == global_variables->table)
  60. ***************
  61. *** 2538,2541 ****
  62. --- 2617,2630 ----
  63. }
  64. }
  65. + #if defined (ARRAY_VARS)
  66. + else if (entry == 0 && newname)
  67. + {
  68. + entry = make_new_array_variable (newname); /* indexed array by default */
  69. + if (entry == 0)
  70. + return entry;
  71. + ind = array_expand_index (name, subp, sublen);
  72. + bind_array_element (entry, ind, value, aflags);
  73. + }
  74. + #endif
  75. else if (entry == 0)
  76. {
  77. ***************
  78. *** 2658,2662 ****
  79. if (nameref_cell (nv) == 0)
  80. return (bind_variable_internal (nv->name, value, nvc->table, 0, flags));
  81. ! return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags));
  82. }
  83. else
  84. --- 2747,2752 ----
  85. if (nameref_cell (nv) == 0)
  86. return (bind_variable_internal (nv->name, value, nvc->table, 0, flags));
  87. ! /* XXX - bug here with ref=array[index] */
  88. ! return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags|ASS_FROMREF));
  89. }
  90. else
  91. *** a/bash-4.3/patchlevel.h 2012-12-29 10:47:57.000000000 -0500
  92. --- b/patchlevel.h 2014-03-20 20:01:28.000000000 -0400
  93. ***************
  94. *** 26,30 ****
  95. looks for to find the patch level (for the sccs version string). */
  96. ! #define PATCHLEVEL 30
  97. #endif /* _PATCHLEVEL_H_ */
  98. --- 26,30 ----
  99. looks for to find the patch level (for the sccs version string). */
  100. ! #define PATCHLEVEL 31
  101. #endif /* _PATCHLEVEL_H_ */