gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18376 - in libmwmodem/src: include main


From: gnunet
Subject: [GNUnet-SVN] r18376 - in libmwmodem/src: include main
Date: Tue, 29 Nov 2011 16:16:56 +0100

Author: ruppa
Date: 2011-11-29 16:16:56 +0100 (Tue, 29 Nov 2011)
New Revision: 18376

Modified:
   libmwmodem/src/include/libmwmodem.h
   libmwmodem/src/main/libmwmodem.c
Log:
Author: Christian Rupp

Modified: libmwmodem/src/include/libmwmodem.h
===================================================================
--- libmwmodem/src/include/libmwmodem.h 2011-11-29 14:18:17 UTC (rev 18375)
+++ libmwmodem/src/include/libmwmodem.h 2011-11-29 15:16:56 UTC (rev 18376)
@@ -48,11 +48,6 @@
 #define MWMODEM_PORT 50243
 
 /**
- * The max length of a udp message
- */
-#define MWMODEM_MAXMESSLENGTH 65507
-
-/**
  * The maximal content for a channel queue
  */
 #define MWMODEM_MAX_QUEUE 64

Modified: libmwmodem/src/main/libmwmodem.c
===================================================================
--- libmwmodem/src/main/libmwmodem.c    2011-11-29 14:18:17 UTC (rev 18375)
+++ libmwmodem/src/main/libmwmodem.c    2011-11-29 15:16:56 UTC (rev 18376)
@@ -53,7 +53,6 @@
        if (-1 == context->socket)
        {
                fprintf(stderr, "Error no socket created: %s", strerror(errno));
-               // LEAK!
                free (context);
                return;
        }       
@@ -151,13 +150,18 @@
        struct MWMODEM_Channel channel;
        const struct MWHeader *hdr;
        struct MWChannel *chl;
+       int package_length;
 
+       octl(context->socket, FIONREAD, &package_length);
 
-       // use ioctl with FIONREAD to determine size of inbound UDP packet => 
only allocated what is needed
-       // (and then stack-allocate that)
+       if (package_length==0)
+       {
+               fprintf(sderr, "Error no message to receive!");
+               return;
+       }
 
        package = malloc(sizeof(struct MWMODEM_Package));
-       buffer = malloc(MWMODEM_MAXMESSLENGTH);
+       buffer = malloc(package_length);
        
        if (recvfrom(fc->socket, *buffer, sizeof(buffer), 0, from, 
from_length)==-1)
        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]