HI,

Just FYI - the value for the community string field is binary.

Regards,
/david t. perkins

On Fri, 16 Jun 2006, Gustaf Gunnarsson wrote:
> I didn't think about that.
> 
> Specifically I am only parsing (and using) the community string of a 
> snmp-trap but it's important to me that things are fail-safe (within 
> reason).
> 
> I've made a wrapper function now ensuring any successful return will 
> contain a null-terminated printable string.
> 
> Thanks for the input!
> 
> //Gustaf
> 
> David T. Perkins wrote:
> > HI,
> > 
> > "Fixing" by putting a "0" on the end, and then calling
> > printf is not a good approach. This is because the
> > value of OCTET STIRNGs are binary, the the result
> > when just doing a printf may not result is a usable
> > output. Even when the value of the OCTET STRING is
> > suppose to be printable, the SNMP agent may have
> > a bug and return a value that contains nonprintable
> > octets. Thus, I suggest that you ALWAYS use a function
> > that takes an OCTET STRING value and creates a displayable
> > string in a supplied buffer, and then printf the resulting
> > buffer.
> > 
> > PS Be aware of OCTET STRINGs whose value is UTF-8, and
> >    know what you want to do for non-US-ASCII display.
Regards,
/david t. perkins



_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to