Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform 0.9.5 built-in "installer" uses stat() incorrectly #4

Open
GoogleCodeExporter opened this issue Mar 14, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Install new terraform 0.9.5 without ~/.terraform existing
2. Start terraform
3. Terraform tries to create ~/.terraform

What is the expected output? What do you see instead?
It should successfully copy PREFIX/share/terraform/ to ~/.prefix. Instead, this 
files at random 
points, and sometimes even works


What version of the product are you using? On what operating system?
Version 0.9.5 on Mac OS X.


The reason for the failure is simple: The code does not check the return value 
of stat, nor does it 
reset the variable st. It then tries to use stat() to check if a given 
directory exists. But if it 
*doesn't* exist, then the variable "st" will not be modified by stat(). hence 
it may contain random 
data. The value of  S_ISDIR(st.st_mode) is undefined in this case, and may be 0 
or 1 or anything 
else.

The attached patch fixes the issue by checking the return value of stat().

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 26 Jan 2010 at 11:02

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant