Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
authoretisserant
Wed, 16 Jul 2008 15:21:04 +0200
changeset 495 b2d6307a89fa
parent 494 aa36efce6e78
child 496 06b489ebe751
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
src/sdo.c
--- a/src/sdo.c	Tue Jul 08 15:14:48 2008 +0200
+++ b/src/sdo.c	Wed Jul 16 15:21:04 2008 +0200
@@ -1509,15 +1509,15 @@
 }
 
 /*!                                                                                                
-**                                                                                                 
-**                                                                                                 
-** @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 @@
     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)