Agree as a basic example.
tmpname1 = "/tmp/file.txt; rm -rf /";
becomes
gunzip -c /tmp/file.txt; rm -rf / > /tmp/atopwrkXXXXXX
Also tmpname2 could be symlinked to /etc/passwd before it is unlinked..
Also tmpname2 could be symlinked to /etc/passwd before it is unlinked..
Yeah, sure, but only if you run atop as root, otherwise it'll just get a "permission denied", and if you can run atop as root with whatever flags you like, you might as well just run 'rm' instead.
It's not a suid binary, so while it's bad code and a smell, I don't think the TOCTOU is a security issue in how it's commonly run (i.e. as an interactive CLI running as your user).