daily pastebin goal
75%
SHARE
TWEET

#ShellShock

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