RE: Am I confused or is read_config_read_octet_string broken?

2004-09-28 Thread Jeff Johnson
The bug report contains a code snippet that itself contains a bug.  The
second code snippet:
len = sizeof(buf);
read_config_read_octet_string(str, (u_char**)buf, len);
snmp_log(LOG_INFO, len:%d, buf:%s\n, len, buf);

The second param to read_config_read_octet_string should be a pointer to
a pointer to the buffer.  In this case it is just passing in a pointer
to the buffer.  In other words, not enough redirection.

Try:
pt = buf; /* or to better illustrate, pt = buf[0] */
len = sizeof(buf);
read_config_read_octet_string(str, pt, len);
snmp_log(LOG_INFO, len:%d, buf:%s\n, len, buf);

There are also multiple examples of correct usage in snmplib/vacm.c

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Tuesday, September 28, 2004 4:48 AM
To: [EMAIL PROTECTED]
Subject: Re: Am I confused or is read_config_read_octet_string broken?

 ...
 I'd say that the basic problem here is that the behaviour is not
 documented properly.  (Like so much else!)
 I'd suggest that:
 
 Robert adding one line before the read will fix your problem:
 Robert len = sizeof(value);
 
 this is the correct approach, and we just need to document it.

As noted in bug 1029287, this correct approach seems to have a bug in
its implementation.

http://sourceforge.net/tracker/index.php?func=detailaid=1029287group_i
d=12694atid=112694



---
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
___
Net-snmp-users mailing list
[EMAIL PROTECTED]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


---
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
___
Net-snmp-users mailing list
[EMAIL PROTECTED]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


Re: Am I confused or is read_config_read_octet_string broken?

2004-09-16 Thread cnelson
 On Wed, 15 Sep 2004 13:09:54 -0400 [EMAIL PROTECTED] wrote:
 CRC I'm trying to use read_config_read_octet_string() (in 5.1.1) 
 and I'm not
 CRC getting the results I expect.
 
 ghost voiceUse the source, Luke.../ghost voice

Yeah, I'm trying (that's where I found the snippet I posted).  But it's not exactly a 
small, clear code base.

 ...
 No, the function is inconsistent in its use of the len parameter. 
 In the case
 of a non-hex string and a user provided buffer, it passes len to a 
 functionthat expects it to be a buffer size.Thus, adding one line 
 before the read will
 fix your problem:
 
len = sizeof(value);

Thanks.



---
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
___
Net-snmp-users mailing list
[EMAIL PROTECTED]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


Am I confused or is read_config_read_octet_string broken?

2004-09-15 Thread cnelson
I'm trying to use read_config_read_octet_string() (in 5.1.1) and I'm not getting the 
results I expect.  It is written to allocate space for the return value if needed:

/*
 * malloc data space if needed (+1 for good measure) 
 */
if (*str == NULL) {
if ((cptr = (u_char *) malloc(*len + 1)) == NULL) {
return NULL;
}
*str = cptr;
} else {
cptr = *str;
}

and if I do:

   ...
   char* pt;
   size_t len;
   char* value;
   ...
   value = NULL;
   read_config_read_octet_string(pt, 
 (u_char**)value,
 len);

I get a value parsed out of the string pointed to by pt.  But, if I do:

   ...
   char* pt;
   size_t len;
   char value[32];
   ...
   read_config_read_octet_string(pt, 
 (u_char**)value,
 len);

len has the same value but only one character is copied into value.  Am I missing 
something obvious and stupid?

Chris



---
This SF.Net email is sponsored by: thawte's Crypto Challenge Vl
Crack the code and win a Sony DCRHC40 MiniDV Digital Handycam
Camcorder. More prizes in the weekly Lunch Hour Challenge.
Sign up NOW http://ad.doubleclick.net/clk;10740251;10262165;m
___
Net-snmp-users mailing list
[EMAIL PROTECTED]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users