From: etisserant Date: Wed, 16 Jul 2008 13:21:04 +0000 (+0000) Subject: Changed getReadResultNetworkDict behaviour about size. Do not copy more data than... X-Git-Url: https://rtime.felk.cvut.cz/gitweb/CanFestival-3.git/commitdiff_plain/38d319ba8d5101fb9dd0b8b3bb70a3013695d327 Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg. --- diff --git a/src/sdo.c b/src/sdo.c index 8f5c216..827bfcc 100644 --- a/src/sdo.c +++ b/src/sdo.c @@ -1509,15 +1509,15 @@ UNS8 readNetworkDictCallback (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subInde } /*! -** -** -** @param d -** @param nodeId -** @param data -** @param size -** @param abortCode -** -** @return +** +** +** @param d +** @param nodeId +** @param data +** @param size pointer to expected size, changed into returned size. Expected size will be truncated to transfered data size +** @param abortCode +** +** @return **/ UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS8 *size, UNS32 * abortCode) @@ -1537,7 +1537,9 @@ UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS8 *size, return d->transfers[line].state; /* Transfert is finished. Put the value in the data. */ - * size = (UNS8)d->transfers[line].count; + /* use transfers[line].count as max size */ + if( (UNS8)d->transfers[line].count < *size ) + *size = (UNS8)d->transfers[line].count; for ( i = 0 ; i < *size ; i++) { # ifdef CANOPEN_BIG_ENDIAN if (d->transfers[line].dataType != visible_string)