Security fix for problem with arguments showing up in Unix ‘ps -ef’ output

#ifndef _OS_H
#define _OS_H
#ifdef SYS5
#undef SYS5
#endif
#ifdef SVR4
#undef SVR4
#endif
#ifdef __pyrsoft
#define _DCOSX_
#define _OS_ "DCOSX"
#define SYS5
#define SVR4
#else
#ifdef pyr
#define _OSX_
#define _OS_ "OSX"
#else
#ifdef _SEQUENT_
#define _PTX_
#define _OS_ "PTX"
#define SYS5
#else
#ifdef sequent
#define _DYNIX_
#define _OS_ "DYNIX"
#else
#ifdef sun
#if defined(_STDC_) || defined(__svr4__) || defined(__SVR4)
#define _SOLARIS_
#define SYS5
#define SVR4
#define _OS_ "SOLARIS"
#else
#define _SUNOS_
#define _OS_ "SUNOS"
#endif
#else
#ifdef hpux
#define _HPUX_
#define _OS_ "HPUX"
#define SYS5
#else
#ifdef ultrix
#define _ULTRIX_
#define _OS_ "ULTRIX"
#else
#ifdef _CX_UX
#define _CX_UX_
#define _OS_ "CXUX"
#define SYS5
#else
#if defined(unix) && defined(i860) /* stratus svr4 */
#define _FTX_
#define _OS_ "FTX"
#define SVR4
#define SYS5
#else
#if defined(unix) && defined(i386) /* ncr svr4 */
#define _NCR_
#define _OS_ "NCR"
#define SVR4
#define SYS5
#else
#if defined(__ncube__) /* nCUBE - for ncc */
#define _VERTEX_
#define _OS_ "VERTEX"
#define SYS5
#else
#if defined(unix) && defined(SVR3) /* ncube sgi */
#define _IRIX_
#define _OS_ "IRIX"
#else
#define _OS_ "UNKNOWN"
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif /* END of _OS_H */
#include 
#ifdef SYS5
#include 
#else
#include 
#define strrchr rindex
#define memset MEMSET /* some BSD systems have a memset() */
char *memset();
#endif
#define JUNK_SIZE 3000
#define JUNK_CHAR ' '
char arg0buf[4096];
char progbuf[4096];
char errbuf[4096];
int main(argc, argv)
int argc;
char *argv[];
{
char *name, *base;
int firstarg;
if (!(name = strrchr(argv[0], '/')))
name = argv[0];
else
name ++; /* get past '/' */
firstarg = (!strcmp(name, "hide")) ? 1 : 0;
if (firstarg && (argc == 1))
{
fprintf(stderr, "Usage: hide program arguments\n");
fprintf(stderr, "   ie: hide sqlplus username/password\n");
fprintf(stderr, "if hide is not named hide, \
it will execute name.hide (useful as a symbolic link)\n");
exit(1);
}
/* Build program name.  If symbolic link mode, use argv[0] || .hide */
strcpy(progbuf, argv[firstarg]);
if (!(base = strrchr(argv[firstarg], '/')))
base = argv[firstarg];
else
base ++; /* get past '/' */
if (!firstarg) strcat(progbuf, ".hide");
/* Build arg0 buffer.  First, fill it with junk */
memset((void *)arg0buf, JUNK_CHAR, JUNK_SIZE);
arg0buf[JUNK_SIZE-1] = '/'; /* set last char to '/' */
/* Prepend real program name - so ps can see what prog is running */
strncpy(arg0buf, base, strlen(base));
/* Append real program name - so prog can see what prog is running */
strcpy(arg0buf + JUNK_SIZE, argv[firstarg]);
/* Assign new arg0 buffer to the argv array */
argv[firstarg] = arg0buf;
/* Start the new program with the shifted arguments */
execvp(progbuf, argv + firstarg);
sprintf(errbuf, "Could not execvp '%s'", progbuf);
perror(errbuf);
exit(1);
}
#ifndef SYS5
char *
memset(s, c, n)
register char *s;
register c, n;
{
register char *p = s;
while (n-- > 0)
*s++ = c;
return (p);
}
#endif /* ifndef SYS5 */

Syed