Hi Dave,
 
I found my mistake, I used
 
strlen(requests->requestvb->val.string) to find the length of the string, but 
this is not null terminated string, so it is returning the longest string I've 
ever set with snmpset, in this case "private"
 
if I use, requests->requestvb->val_len to retrieve the length, and use
 
strncpy(my_buff, requests->requestvb->val.string, 
requests->requestvb->val_len); 
my_buff[ requests->requestvb->val_len + 1] = '\0';
 
it works fine.
 
Thanks so much!!
 
Leo;


--- On Mon, 10/18/10, Dave Shield <d.t.shi...@liverpool.ac.uk> wrote:


From: Dave Shield <d.t.shi...@liverpool.ac.uk>
Subject: Re: problem encountered while issuing multiple snmpset on octetstring 
oids
To: "Leo Lin" <hayashi_...@yahoo.com>
Cc: "Net-snmp-users" <net-snmp-users@lists.sourceforge.net>
Date: Monday, October 18, 2010, 7:31 AM


On 18 October 2010 15:13, Leo Lin <hayashi_...@yahoo.com> wrote:
> Then, I issue an snmpset and modify the contents to a strlen less than 
> 'private' (7).
> snmpset does it right the first time, but consecutives calls to snmpset,
> gives me the remainder of 'private'

It sounds as if you are forgetting to add the null terminator to
your internal string buffer, when setting the new value.


> I used DEBUGMSGTL to track the len of requests->requestvb->val.string,
> and it shows me that for snmpset to "leo", the strlen is still 7 instead of 3.

What exactly do you mean by this?
What is the value of 'requests->requestvb->val_len' ?

Remember that the Net-SNMP library uses a (value+length) approach
to varbind values,  rather than assuming all strings will be null-terminated.

> I also made sure that I've clear my buffer using
>    memset(_myoid, '\0', _myoid_len);

That's the OID buffer.
What are you doing with the buffer that holds the string value?

Dave



      
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to