> > > The line
 > > >
 > > >    strncpy(refbase,refhost,strlen(refhost));
 > > >
 > > > in FuzzyHostMatch in item.c creates an unterminated string, which, not
 > > > unexpectedly, leads to unpredictable results.
 > > >
 > > > Jim
 > > >
 > > This is impossible Jim. strncpy always terminates strings
 > 
 > I would agree with you if we were talking about strcpy, but for strncpy
 > my man page says:
 > 
 >   The strncpy() function is similar, except that not more than n bytes of
 >   src  are copied. Thus, if there is no null byte among the first n bytes
 >   of src, the result will not be null-terminated.
 > 
 > If only strlen(refhost) bytes are copied from refhost then they don't
 > include the terminating null. It should strlen(refhost) + 1, or strcpy
 > should be used. 
 > 
 > A rebuilt 2.2.1 with the patch from the '2.2.1 broken HostRange again?'
 > thread on Mon Jun 25 21:51:47 CEST 2007 which worked yesterday stopped
 > working today. It was when I saw strange characters in the debug output
 > that I suspected what I found.

Can you reproduce this behavior?  Have you verified that 
using strcpy() works for you??

It seems that both refbase and refhost are CF_MAXVARSIZE 
in size and and refhost is guaranteed to be null terminated.

steve
- - -
_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

Reply via email to