[ILUG-BOM] Buggy C prog

Philip S Tellis philip@[EMAIL-PROTECTED]
Fri Sep 27 10:27:12 IST 2002


On Thu, 26 Sep 2002, Nikhil Joshi wrote:

> I've tried this simple prog to encrypt a file using XOR
> 
> But it gives "Segmentation Fault " in 'interactive' mode (pls see the
> source code)

hehe.

didn't anyone tell you that you have to allocate memory before you can 
gets into it?

char *arg[4];
...

gets(arg[1]);

man gets:

       gets() reads a line from stdin into the buffer pointed  to
                                       ^^^^^^^^^^^^^^^^^^^
       by  s  until either a terminating newline or EOF, which it
       replaces with '\0'.  No check for buffer overrun  is  per-
       formed (see BUGS below).

My guess is it's purely coincidental that your code worked on DOS.

-- 
In Mexico we have a word for sushi: bait.
		-- Josi Simon







More information about the Linuxers mailing list