Dvolgyes fixes

Hi,

Please, review these fixes I made. They are basically string and memory handling related changes:
- some str*cpy change: size parameter, NUL termination, etc.
- snprintf: the size of the memory region contains the last \0, so there is no need for .... ,SIZE-1, like constants
- sometimes strncpy is just a slow implementation of memcpy
  (e.g. len=strlen(source); strncpy(target,source,len);  
   In this case strncpy will NOT copy the last \0, therefore memcpy is fine. (Or strcpy without strlen, it depends on the situation.))
 - some other small fixes.

Environment: I tested the code with tokyocabinet, using Ubuntu 12.04 (x64), gcc 4.6.3


It could prevent "use after free" bugs. (Or at least they will be visible.)
Of course, the whole "strs" shouldn't be used after FreeStringArray.
But right now if you just call "FreeStringArray" on an array (A), and a
line below you use again this "A" array, everything will just look fine.
And actually, the "free" is a system call, which requires tens of thousand
of CPU cycles, so this extra NULL-ing costs basically nothing.


On Thu, Jun 12, 2014 at 1:35 PM, Edward Welbourne <notifications@github.com>
wrote:

> In libutils/string_lib.c:
>
> > @@ -847,10 +847,10 @@ void FreeStringArray(char **strs)
> >      for (i = 0; strs[i] != NULL; i++)
> >      {
> >          free(strs[i]);
> > +        strs[i] = NULL;
>
> Why bother ?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/cfengine/core/pull/1433/files#r13696946>.
>