You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove broken frivolous function from install script
The "template" installation script contained a `get()` function used to make an HTTP request.
The response body is required by the caller, but shell functions do not support returning content as you might do when
using a more capable programming language.
As a workaround, the script author set up a system where the caller passed an arbitrary variable name to the function,
which the function then assigns with the response body string.
This was done using the `eval` builtin. The `eval` command was quoted in a naive manner, not considering that the body
content could contain any arbitrary characters. This made it possible that contents of the response body could be
unintentionally executed on the user's machine.
In the context of the installation script, this happened under the following conditions:
- The release download was not available from Arduino's downloads server
- The response body from the Releases GitHub API request contained single quotes
The most minimal fix would likely have been to change the `eval` command so that the variable containing the response
body text was not expanded in the command:
eval "$1=\$GET_BODY"
However, this problem has provided clear evidence that best practices are to avoid `eval` altogether unless absolutely
necessary. Since it is only called once, the entire function is not necessary (and in fact it is questionable whether
there is any real value in the entire GitHub releases fallback system). So I decided the best fix was to do away with
the function altogether, replacing its single call with the contents of the former function. This removed unnecessary
complexity from the script without any decrease in efficiency or increase in maintenance burden.
0 commit comments