Hi Dave,

That piece of code(lines 196-198) is generated by mib2c.

In fact, besides the change mentioned in your email, there is another change needs to be done inside memcpy.
I have verified the following code works correct.

rowreq_ctx->data.historyControlDataSource_len =
historyControlDataSource_len ;
memcpy(rowreq_ctx->data.historyControlDataSource,
historyControlDataSource,
rowreq_ctx->data.historyControlDataSource_len
* sizeof(rowreq_ctx->data.historyControlDataSource[0]));

I think the mib2c generation scripts need to be fixed. Another patch may be?
Thanks.
--
Emi

Inactive hide details for Dave Shield <[EMAIL PROTECTED]>Dave Shield <[EMAIL PROTECTED]>


          Dave Shield <[EMAIL PROTECTED]>

          08/10/2005 03:18 AM


To

[EMAIL PROTECTED]

cc

[email protected]

Subject

Re: mib2c OID type populate OID of length 4 times longer, e.g. historyControlDataSource

On Tue, 2005-08-09 at 14:47 -0500, [EMAIL PROTECTED] wrote:
> Hi Robert,
>
> Using the patch you sent me on 7/25, I still have problem with mib2c
> generated OID type such as historyControlDataSource. See the snmpwalk
> result below, the populated oid length is 4 times of it should be.
>
> $ snmpwalk localhost historyControlDataSource
> RMON-MIB::historyControlDataSource.1 = OID:
> IF-MIB::ifIndex.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0
>
> I attached mib2c generated template code, only
> historyControlTable_data_access.c is modified

I'm immediately suspicious of the following statement:
(lines 196-198)

       rowreq_ctx->data.historyControlDataSource_len =
           historyControlDataSource_len *
           sizeof(rowreq_ctx->data.historyControlDataSource[0]);


Both OIDs and string values are held as (length,value) pairs, but
I'd expect the length field to be the number of array elements.
For strings, this is exactly the same as the amount of memory used,
but that's not true for OID values.


Try replacing this statement with:

       rowreq_ctx->data.historyControlDataSource_len =
           historyControlDataSource_len;

Dave

GIF image

Reply via email to