Hello The variable requests->requestvb->val.string is not '\0' terminated string so you cannot use strlen().
You must use requests->requestvb->val_len to determine the length of the data. Eirik Nordbrøden, moreCom A/S (+47) 90174789 ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of wqs Sent: 28. november 2007 04:26 To: net-snmp-coders Subject: snmpset problem I have compiled my module into the agent,and run snmpset,first time I set a long string:"aaaa",it's ok;next time,I set a shorter string:"bb",but the value in the mib became "bbaaa",how could that happen? my code related: case MODE_SET_ACTION: if ( sizeof(def_nodeType) < strlen(requests->requestvb->val.string) { netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGLENGTH); } memset(def_nodeType,'\0',sizeof(def_nodeType)); printf("set node type:%s\n",def_nodeType);//output blank string printf("val.string:%s\n",(u_char *)requests->requestvb->val.string);//output "bbaaa" memcpy(def_nodeType ,(u_char *)requests->requestvb->val.string ,strlen(requests->requestvb->val.string)); ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders