Why is this working?
#10

Quote:
Originally Posted by Vince
View Post
It doesn't. This is known as buffer overflow. Retrieving a string from memory is basically saying: start reading at this address and continue reading until null (\0) is encountered. Thereby possibly extending into address space occupied by other variables if you're lucky or into address space reserved for critical processes if you're not so lucky. In the latter case the server will probably crash.

Create another array right after your existing one. Don't store anything in it. Do your strcat stuff and then print out both arrays afterwards. Although not guaranteed, it is reasonable to assume that the second array will be placed adjacent to the first one in memory, so even though you didn't explicitly store anything in the second array it will probably contain some text.
Oh I see, thanks!
Reply


Messages In This Thread
Why is this working? - by Stinged - 03.01.2017, 07:52
Re: Why is this working? - by Gammix - 03.01.2017, 09:35
Re: Why is this working? - by PrO.GameR - 03.01.2017, 10:07
Re: Why is this working? - by SyS - 03.01.2017, 11:30
Re: Why is this working? - by Stinged - 03.01.2017, 11:32
Re: Why is this working? - by SyS - 03.01.2017, 11:39
Re: Why is this working? - by Spmn - 03.01.2017, 11:56
Re: Why is this working? - by Stinged - 03.01.2017, 14:14
Re: Why is this working? - by Vince - 03.01.2017, 18:02
Re: Why is this working? - by Stinged - 03.01.2017, 18:57

Forum Jump:


Users browsing this thread: 1 Guest(s)