]> rtime.felk.cvut.cz Git - CanFestival-3.git/commitdiff
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than...
authoretisserant <etisserant>
Wed, 16 Jul 2008 13:21:04 +0000 (13:21 +0000)
committeretisserant <etisserant>
Wed, 16 Jul 2008 13:21:04 +0000 (13:21 +0000)
src/sdo.c

index 8f5c216a83fe12183b04a02185e2405af2e93685..827bfccb0fd29e11c36ed915cd29b76c3989e226 100644 (file)
--- 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)