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.

96 lines
3.1 KiB

  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 4.3
  4. Patch-ID: bash43-031
  5. Bug-Reported-by: lolilolicon <lolilolicon@gmail.com>
  6. Bug-Reference-ID: <CAMtVo_Nz=32Oq=zWTb6=+8gUNXOo2rRvud1W4oPnA-cgVk_ZqQ@mail.gmail.com>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2014-08/msg00139.html
  8. Bug-Description:
  9. The new nameref assignment functionality introduced in bash-4.3 did not perform
  10. enough validation on the variable value and would create variables with
  11. invalid names.
  12. Patch (apply with `patch -p0'):
  13. --- a/subst.h
  14. +++ b/subst.h
  15. @@ -47,6 +47,7 @@
  16. #define ASS_MKASSOC 0x0004
  17. #define ASS_MKGLOBAL 0x0008 /* force global assignment */
  18. #define ASS_NAMEREF 0x0010 /* assigning to nameref variable */
  19. +#define ASS_FROMREF 0x0020 /* assigning from value of nameref variable */
  20. /* Flags for the string extraction functions. */
  21. #define SX_NOALLOC 0x0001 /* just skip; don't return substring */
  22. --- a/variables.c
  23. +++ b/variables.c
  24. @@ -2516,10 +2516,27 @@ bind_variable_internal (name, value, tab
  25. HASH_TABLE *table;
  26. int hflags, aflags;
  27. {
  28. - char *newval;
  29. + char *newname, *newval;
  30. SHELL_VAR *entry;
  31. +#if defined (ARRAY_VARS)
  32. + arrayind_t ind;
  33. + char *subp;
  34. + int sublen;
  35. +#endif
  36. + newname = 0;
  37. +#if defined (ARRAY_VARS)
  38. + if ((aflags & ASS_FROMREF) && (hflags & HASH_NOSRCH) == 0 && valid_array_reference (name))
  39. + {
  40. + newname = array_variable_name (name, &subp, &sublen);
  41. + if (newname == 0)
  42. + return (SHELL_VAR *)NULL; /* XXX */
  43. + entry = hash_lookup (newname, table);
  44. + }
  45. + else
  46. +#endif
  47. entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table);
  48. +
  49. /* Follow the nameref chain here if this is the global variables table */
  50. if (entry && nameref_p (entry) && (invisible_p (entry) == 0) && table == global_variables->table)
  51. {
  52. @@ -2550,6 +2567,16 @@ bind_variable_internal (name, value, tab
  53. var_setvalue (entry, make_variable_value (entry, value, 0));
  54. }
  55. }
  56. +#if defined (ARRAY_VARS)
  57. + else if (entry == 0 && newname)
  58. + {
  59. + entry = make_new_array_variable (newname); /* indexed array by default */
  60. + if (entry == 0)
  61. + return entry;
  62. + ind = array_expand_index (name, subp, sublen);
  63. + bind_array_element (entry, ind, value, aflags);
  64. + }
  65. +#endif
  66. else if (entry == 0)
  67. {
  68. entry = make_new_variable (name, table);
  69. @@ -2670,7 +2697,8 @@ bind_variable (name, value, flags)
  70. normal. */
  71. if (nameref_cell (nv) == 0)
  72. return (bind_variable_internal (nv->name, value, nvc->table, 0, flags));
  73. - return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags));
  74. + /* XXX - bug here with ref=array[index] */
  75. + return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags|ASS_FROMREF));
  76. }
  77. else
  78. v = nv;
  79. --- a/patchlevel.h
  80. +++ b/patchlevel.h
  81. @@ -25,6 +25,6 @@
  82. regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
  83. looks for to find the patch level (for the sccs version string). */
  84. -#define PATCHLEVEL 30
  85. +#define PATCHLEVEL 31
  86. #endif /* _PATCHLEVEL_H_ */