On 22 August 2012 09:11, Schmoll Walter <walter.schm...@andritz.com> wrote:
> ... as far as I know, strlcpy is not standard and only available on BSD 
> related
> systems and slightly incompatible on Solaris (the return value is different)
> but not on Linux related systems nor on Windows (just checked with my Ubuntu 
> 10.04 and VS2010).

The issue of compatability was my first reaction too.

> Probably the module/code you are discussing is only used on BSD
> or there is an implementation of strlcpy  somewhere in net-snmp for systems 
> without.

The second is actually true.   (See snmplib/strlcpy.c)

I have no great preference between the two.
However a quick analysis of the current code base seems to
indicate an overwhelming preponderance of 'strlcpy' rather
than 'strncpy'

    $ git checkout  V5-6-patches
    $ find . -name \*.c | xargs grep strlcpy | wc -l
    187
    $ find . -name \*.c | xargs grep strncpy | wc -l
    1
         (in snmplib/snmptsm.c)

    $ git checkout  master
    $ find . -name \*.c | xargs grep strlcpy | wc -l
    185
    $ find . -name \*.c | xargs grep strncpy | wc -l
    6
         (four in ucd-snmp/dlmod.c,
          one in snmplib/sd-daemon.c, plus snmptsm.c)


For consistency, it would seem sensible to use the same
approach throughout  (always assuming that the null-terminated
assumption of strlcpy holds).

Dave

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to