Guest User

Untitled

a guest
Sep 25th, 2014
12,809
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #shellshock fix. Nuke the whole feature from orbit, it's the only way to be sure. -@andreasdotorg
  2.  
  3. diff --git a/variables.c b/variables.c
  4. index cdc54bc..1a98efa 100644
  5. --- a/variables.c
  6. +++ b/variables.c
  7. @@ -347,85 +347,25 @@ initialize_shell_variables (env, privmode)
  8.  
  9. temp_var = (SHELL_VAR *)NULL;
  10.  
  11. - /* If exported function, define it now. Don't import functions from
  12. - the environment in privileged mode. */
  13. - if (privmode == 0 && read_but_dont_execute == 0 && STREQN ("() {", string, 4))
  14. + ro = 0;
  15. + if (posixly_correct && STREQ (name, "SHELLOPTS"))
  16. {
  17. - string_length = strlen (string);
  18. - temp_string = (char *)xmalloc (3 + string_length + char_index);
  19. -
  20. - strcpy (temp_string, name);
  21. - temp_string[char_index] = ' ';
  22. - strcpy (temp_string + char_index + 1, string);
  23. -
  24. - if (posixly_correct == 0 || legal_identifier (name))
  25. - parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);
  26. -
  27. - /* Ancient backwards compatibility. Old versions of bash exported
  28. - functions like name()=() {...} */
  29. - if (name[char_index - 1] == ')' && name[char_index - 2] == '(')
  30. - name[char_index - 2] = '\0';
  31. -
  32. - if (temp_var = find_function (name))
  33. - {
  34. - VSETATTR (temp_var, (att_exported|att_imported));
  35. - array_needs_making = 1;
  36. - }
  37. - else
  38. - {
  39. - if (temp_var = bind_variable (name, string, 0))
  40. - {
  41. - VSETATTR (temp_var, (att_exported | att_imported | att_invisible));
  42. - array_needs_making = 1;
  43. - }
  44. - last_command_exit_value = 1;
  45. - report_error (_("error importing function definition for `%s'"), name);
  46. - }
  47. -
  48. - /* ( */
  49. - if (name[char_index - 1] == ')' && name[char_index - 2] == '\0')
  50. - name[char_index - 2] = '('; /* ) */
  51. + temp_var = find_variable ("SHELLOPTS");
  52. + ro = temp_var && readonly_p (temp_var);
  53. + if (temp_var)
  54. + VUNSETATTR (temp_var, att_readonly);
  55. }
  56. -#if defined (ARRAY_VARS)
  57. -# if ARRAY_EXPORT
  58. - /* Array variables may not yet be exported. */
  59. - else if (*string == '(' && string[1] == '[' && string[strlen (string) - 1] == ')')
  60. + temp_var = bind_variable (name, string, 0);
  61. + if (temp_var)
  62. {
  63. - string_length = 1;
  64. - temp_string = extract_array_assignment_list (string, &string_length);
  65. - temp_var = assign_array_from_string (name, temp_string);
  66. - FREE (temp_string);
  67. - VSETATTR (temp_var, (att_exported | att_imported));
  68. + if (legal_identifier (name))
  69. + VSETATTR (temp_var, (att_exported | att_imported));
  70. + else
  71. + VSETATTR (temp_var, (att_exported | att_imported | att_invisible));
  72. + if (ro)
  73. + VSETATTR (temp_var, att_readonly);
  74. array_needs_making = 1;
  75. }
  76. -# endif /* ARRAY_EXPORT */
  77. -#endif
  78. -#if 0
  79. - else if (legal_identifier (name))
  80. -#else
  81. - else
  82. -#endif
  83. - {
  84. - ro = 0;
  85. - if (posixly_correct && STREQ (name, "SHELLOPTS"))
  86. - {
  87. - temp_var = find_variable ("SHELLOPTS");
  88. - ro = temp_var && readonly_p (temp_var);
  89. - if (temp_var)
  90. - VUNSETATTR (temp_var, att_readonly);
  91. - }
  92. - temp_var = bind_variable (name, string, 0);
  93. - if (temp_var)
  94. - {
  95. - if (legal_identifier (name))
  96. - VSETATTR (temp_var, (att_exported | att_imported));
  97. - else
  98. - VSETATTR (temp_var, (att_exported | att_imported | att_invisible));
  99. - if (ro)
  100. - VSETATTR (temp_var, att_readonly);
  101. - array_needs_making = 1;
  102. - }
  103. - }
  104.  
  105. name[char_index] = '=';
  106. /* temp_var can be NULL if it was an exported function with a syntax
RAW Paste Data