changeset 308:7e2c809b7892 beta1

Fix small error
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 08 Jan 2009 16:45:55 +0900
parents a4592b91368c
children 0e4c6269bddf
files waaad/message.c
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/waaad/message.c	Thu Jan 08 15:37:51 2009 +0900
+++ b/waaad/message.c	Thu Jan 08 16:45:55 2009 +0900
@@ -741,15 +741,12 @@
 static int _msg_buf_avp(unsigned char * buffer, size_t buflen, size_t * offset,  _msg_avp_t * avp)
 {
 	dict_avp_data_t dictdata;
-	size_t offsetini;
 	
 	TRACE_ENTRY("%p %d %p %p", buffer, buflen, offset, avp);
 	
 	if ((buflen - *offset) < avp->avp_public.avp_len)
 		return ENOSPC;
 	
-	offsetini = *offset;
-	
 	/* Write the header */
 	PUT_in_buf_32(avp->avp_public.avp_code, buffer + *offset);
 	*offset += 4;
@@ -771,8 +768,9 @@
 		
 		if ( avp->avp_source != NULL ) {
 			/* the message was not parsed completely */
-			memcpy(&buffer[*offset], avp->avp_source, avp->avp_public.avp_len + offsetini - *offset);
-			*offset = PAD4(avp->avp_public.avp_len + offsetini);
+			size_t datalen = avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags);
+			memcpy(&buffer[*offset], avp->avp_source, datalen);
+			*offset += PAD4(datalen);
 		} else {
 			/* the content is stored in rawdata */
 			memcpy(&buffer[*offset], avp->avp_rawdata, avp->avp_rawlen);
@@ -970,9 +968,11 @@
 			/* we must copy the data from the source to the internal buffer area */
 			CHECK_PARAMS( !avp->avp_rawdata  );
 			
-			CHECK_MALLOC(  avp->avp_rawdata = malloc(avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ))  );
+			avp->avp_rawlen = avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags );
 			
-			memcpy(avp->avp_rawdata, avp->avp_source, avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ));
+			CHECK_MALLOC(  avp->avp_rawdata = malloc(avp->avp_rawlen)  );
+			
+			memcpy(avp->avp_rawdata, avp->avp_source, avp->avp_rawlen);
 			avp->avp_source = NULL;
 			
 			TRACE_DEBUG(FULL, "Unsupported optional AVP found, raw source data saved in avp_rawdata.");
"Welcome to our mercurial repository"