From: Peter H. <pe...@sa...> - 2003-10-14 16:11:36
|
> I don't know why snprintf makes it easier to find such a bug(because the > bugg y codes will work anyway by snprintf, maybe), but I agree snprintf is > safer in this situation too. The problem is that snprintf is a not > portable function, I'll replace sprintf with a wrapper function > kik_snprintf. The reason snprintf would have made it easier was because on my machine it was crashing in random different places. Most often it was crashing inside of fopen() called by XMOpen() called by some other functions, but I couldn't find anything wrong with the arguments to any of those so I suspected it was some sort of memory overflow. So I compiled it with ElectricFence to see if that would help. That found it relatively quickly, but I know from experience sometimes it is really hard to find those memory overwrite bugs even if you use something like ElectricFence. I usually use the code for the snprintf functions from FreeBSD when they aren't available for some platforms. |