Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!oliveb!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.lang.c,comp.unix.questions Subject: Re: Destroying arguments Message-ID: <19131@sun.uucp> Date: Mon, 18-May-87 16:18:57 EDT Article-I.D.: sun.19131 Posted: Mon May 18 16:18:57 1987 Date-Received: Tue, 19-May-87 05:43:15 EDT References: <292@osupyr.UUCP> <239@polyof.UUCP> <485@bene.UUCP> <6723@mimsy.UUCP> Sender: news@sun.uucp Followup-To: comp.unix.questions Distribution: comp.unix.questions Lines: 34 Xref: mnetor comp.lang.c:2212 comp.unix.questions:2394 This really isn't a C question at all, it's a UNIX question, so I'll redirect it where it should have been sent in the first place. > Newsgroups: comp.lang.c > Distribution: comp.unix.questions In fact, it looks like the orignal poster may have tried directing it there, but goofed. > Alas, this wonderfully simple technique simply does not work with > the 4BSD `ps', which reads the strings themselves, not the pointers > thereto. As do most other versions of "ps". The 3B2 version of "ps" does it differently; the kernel stashes a string away in the U area that contains the original arguments used to invoke the program. (I have no idea whether this was done because somebody thought this was the right way to do things, or because they couldn't figure out how to snarf the arguments up on a machine whose stack grows upward in memory....) On this machine, you *can't* smash your argument list. Period. The answer is "forget it". In general, it can't be done. Some versions of "crypt" write '\0' all over the password it is handed, which means it'll smash the argument if that was where the key appeared, but 1) this won't work on a system that works the way 3B2 UNIX does and 2) still leaves a window in which the argument can be seen. We won't mention that it also leaves the encryption key on your screen when you type the command, or that using "crypt" in this fashion in a *script* is a very bad mistake as it leaves the encryption key in a file. In short, the answer is "always get encryption keys from the user, and turn off echoing when you do so".