I've noticed that several threads have a few insecure/instable code segments in them, so I though I'd just give you all a few pointers on improving the dire trend in software development today to leave buggy pieces of elephant feces in apps.
Whenever copying from one area of memory to another, ALWAYS use the size of the destination as the amount of memory to copy, never the source. e.g.:
memcpy(dest, src, sizeof(dest)); // OR
strncmp(dest, src, sizeof(dest));
This simple, and maybe even obvious piece of advise is so foten ignored, and so often the cause of many of the problems involved in computing (especially when it comes to networking).
If you have any other tips, feel free to post them.
Note to felis: I've made this sticky so people will see it, but if you object, I'll make it unsticky.