Hi, Magnus
In some log, I replace nameData with the hex string of nameData.
Maybe the log file can look better.
The patch is in the attachment. Please check it.
Best Regards!
Zhu Yanjun
On 11/28/2013 02:55 PM, zhuyj wrote:
On 11/26/2013 02:52 PM, Magnus Fromreide wrote:
On Mon, 2013-11-25 at 19:04 +0800, zhuyj wrote:
On 11/25/2013 02:34 AM, Magnus Fromreide wrote:
On Fri, 2013-11-22 at 14:27 +0800, zhuyj wrote:
4.patch -p1 < V5-7-patches-snmpTargetParam_support_zero_OID.patch
snmpTargetAddrEntry.c:
Chunk #2 is unnecessary - setting members to 0 before freeing the
object they are members of.
snmpTargetAddrEntry.h:
Putting the variable in the hole after nameLen will leave the size of
targetAddrTable_struct unchanged while the suggested location will
expand the size of it by 4 (or 8 on 64-bit) bytes.
snmpTargetParamsEntry.c:
Chunk #2 is unnecessary - setting a member to 0 before freeing the
object it is a member of.
Chunk #9? (get_paramEntry) - it would be more efficient and correct
to check that nameLen == ptr->paramNameLen before
memcmp'ing
name and paramName, in particular if nameLen <
paramNameLen.
target.c:
Certificate lookup under DTLS uses only the part of the name up to the
first '\0'.
Hi, MF
I agree with other advices from you. But I do not understand this:
target.c:
Certificate lookup under DTLS uses only the part of the name up to the
first '\0'.
Would you like to explain this in details? Thanks a lot.
Sure.
target/target.c:205
cert = netsnmp_cert_find(NS_CERT_IDENTITY, NS_CERTKEY_TARGET_PARAM,
targaddrs->params);
Now, assume that targaddrs->params contains embedded NUL characters.
Hi, Magnus
I made 2 patches to support params and nameData in target/target.c:205
cert = netsnmp_cert_find(NS_CERT_IDENTITY, NS_CERTKEY_TARGET_PARAM,
targaddrs->params);
....
cert = netsnmp_cert_find(NS_CERT_REMOTE_PEER, NS_CERTKEY_TARGET_ADDR,
buf);
....
Please check it. Thanks a lot.
Zhu Yanjun
patch -p1 < V5-7-patches-fix-param-length.patch
patch -p1 < V5-7-patches-conf-support.patch
Why the memset's before read_config_save_octet_string?
An example is as below.
If variable tmp is used as the line1, there are 6 'x' in this variable
tmp.
we will copy 4 'y' to tmp, now the variable tmp is as below line2 if
we do not
memset tmp. It is not what we expect.
line1: tmp: xxxxxx
line2: using: yyyyxx
You can't use NUL as a end of string marker since NUL is a perfectly
valid character. When handing strings to printf you get around that with
printf("%.*s", tmp, 4);
For other methods one usually have to add a method that takes a string
width.
/MF
>From 8675d3b2c94f3119a946d7f9e68c5c203a244274 Mon Sep 17 00:00:00 2001
From: yzhu1 <yanjun....@windriver.com>
Date: Thu, 28 Nov 2013 16:07:03 +0800
Subject: [PATCH 6/6] replace nameData with nameDate hex string in log
Signed-off-by: yzhu1 <yanjun....@windriver.com>
---
agent/mibgroup/target/target.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/agent/mibgroup/target/target.c b/agent/mibgroup/target/target.c
index 5c94a4d..91315ce 100755
--- a/agent/mibgroup/target/target.c
+++ b/agent/mibgroup/target/target.c
@@ -69,9 +69,13 @@ get_target_sessions(char *taglist, TargetFilterFunction * filterfunct,
if (netsnmp_tdomain_support
(targaddrs->tDomain, targaddrs->tDomainLen, NULL, NULL) == 0) {
+ char tmp[1024] = {0};
+ read_config_save_octet_string(tmp,
+ (const u_char *)targaddrs->nameData,
+ targaddrs->nameLen);
snmp_log(LOG_ERR,
"unsupported domain for target address table entry %s\n",
- targaddrs->nameData);
+ tmp);
}
/*
@@ -220,7 +224,7 @@ get_target_sessions(char *taglist, TargetFilterFunction * filterfunct,
cert->fingerprint);
}
/*use nameData hex string to find*/
- memset(tmp, 0, 1024);
+ memset(tmp, 0, 1024);
read_config_save_octet_string(tmp,
(const u_char *)targaddrs->nameData,
targaddrs->nameLen);
@@ -260,10 +264,14 @@ get_target_sessions(char *taglist, TargetFilterFunction * filterfunct,
if (param->mpModel == SNMP_VERSION_3 &&
param->secModel != SNMP_SEC_MODEL_USM &&
param->secModel != SNMP_SEC_MODEL_TSM) {
+ char tmp[1024] = {0};
+ read_config_save_octet_string(tmp,
+ (const u_char *)targaddrs->nameData,
+ targaddrs->nameLen);
snmp_log(LOG_ERR,
"unsupported mpModel/secModel combo %d/%d for target %s\n",
param->mpModel, param->secModel,
- targaddrs->nameData);
+ tmp);
/*
* XXX: memleak
*/
--
1.7.9.5
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders