Skip to content

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

@GoogleCodeExporter

Description

@GoogleCodeExporter
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:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions