• Welcome to Valhalla Legends Archive.
 

A better random

Started by Barabajagal, July 29, 2008, 06:10 PM

Previous topic - Next topic

brew

Quote from: Andy on July 30, 2008, 05:41 PM
My program already overwrites system files, seeing as it updates files stored in the System32 folder (or SysWOW64 if you're on an x64 OS), since it seemed like a better place to store runtimes than the application directory in order to keep things simple for users.
Nice, at the cost of requring administrator permissions to update!

Quote from: iago on July 30, 2008, 06:12 PM
And for what it's worth, he didn't specify an OS or a language or anything else in his initial post, so I gave a generic answer. :)
Oh come on, we already knew the answer would be "Microsoft Windows XP, Visual Basic 6" :P
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Barabajagal

Brew, stuff it.
iago, I'm dealing with the system I'm on for a program that can only run on the system I'm on. When I'm writing programs independent of the OS, I'll write them so they work for any OS. Riding a bicycle doesn't require a rear-view mirror.

iago

Defensive programming should be a habit.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


MyndFyre

#18
Quote from: iago on July 30, 2008, 06:12 PM
It's probably ok if per-user temp files are used, but I think it's important to get into good habits no matter which OS you're on.
Why shouldn't you write to a system-provided temp directory just because other OSes use an inherently insecure method for storing temporary files? :P

What that really means is, if you want you can create a level of indirection such as, CreateTemporaryFile() that calls the appropriate OS-specific services for doing so.  I don't think it's reasonable to expect there to always be a global, portable API call for generating temporary files; however, Windows provides an easy set of API calls in order to retrieve this information: GetTempPath and GetTempFileName.  Note that GetTempPath uses the TMP and TEMP environment variables; while they can be modified, it requires an administrator to do so.  I don't know XP's default settings (but I know the behavior is to user-scope temp files), but Vista defaults both to %USERPROFILE%\AppData\Local\Temp, which ends up being the same result (user-scoped files).

I certainly don't advocate writing to the system folder in any scenario except installing a device driver, and even that's not necessary.

But let's not be coy.  It's not "un-defensive" to create temporary files in the Windows temporary file path.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.