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


Well, could be.
But why 60 bytes?
Of course, regardless of the size, it should be NIL terminated, therefore
the "strncpy" should be fixed.
The allocated memory size is "CF_BUFSIZE", so could be just
strlcpy(,,CF_BUFSIZE);
(if nothing else will be append later to the "dest").

Anyway, I can't remember why I chose "strncpy", "strlcpy" looks fine for me.


On Thu, Jun 12, 2014 at 1:27 PM, Edward Welbourne <notifications@github.com>
wrote:

> In cf-monitord/mon_network_sniffer.c:
>
> > @@ -395,6 +395,7 @@ static void AnalyzeArrival(Item *ip_addresses, long iteration, char *arrival, do
> >          else
> >          {
> >              strncpy(dest, src, 60);
> > +            dest[60] = '\0';
>
> Why not use strlcpy(,,61) in place of the strncpy ?
> (Pre-existing) I also notice some snprintf()s with bogus array sizes above.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/cfengine/core/pull/1433/files#r13696746>.
>