When you are about to unpack a tarball you didn't create it's a good idea to run the -t
flag instead of just assuming it's been packed in a sensible way.
tar -tzf foo.tar.gz
This lists all of the files in the tarball so you can be sure it's not going to extract to somewhere you didn't expect.
If you need tar to extract to a different location then you can use the -C
flag to tell tar to cd to that directory first and then unpack the contents there.