system() --- the C function from hell?

Robert J Woodhead trebor at biar.UUCP
Mon May 1 05:55:46 AEST 1989


In article <1827 at uop.edu> jeff at uop.edu (Jeff Ferguson) writes:
>int lowp, hip;
>scanf("%d", &hip);
>scanf("%d", &lowp);
>sprintf(str, "/bin/mkdir directory");
>system(str);

I note that you haven't given us the definition of ``str''.  I would
like to see this definition,  for if str was not long enough to hold
"/bin/mkdir directory" plus the termination byte, and was defined so
the compiler put it in memory right before lowp and hip, it would be
possible for the sprintf to trash the integers.

-- 
Robert J Woodhead, Biar Games, Inc.  ...!uunet!biar!trebor | trebor at biar.UUCP
"The NY Times is read by the people who run the country.  The Washington Post
is read by the people who think they run the country.   The National Enquirer
is read by the people who think Elvis is alive and running the country..."



More information about the Comp.unix.wizards mailing list