gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r11792 - in gnunet/src: fs include nat/libnatpmp topology t


From: gnunet
Subject: [GNUnet-SVN] r11792 - in gnunet/src: fs include nat/libnatpmp topology transport util
Date: Thu, 17 Jun 2010 23:12:09 +0200

Author: grothoff
Date: 2010-06-17 23:12:09 +0200 (Thu, 17 Jun 2010)
New Revision: 11792

Modified:
   gnunet/src/fs/fs.c
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/fs_namespace.c
   gnunet/src/fs/fs_publish.c
   gnunet/src/fs/fs_search.c
   gnunet/src/fs/fs_unindex.c
   gnunet/src/fs/gnunet-search.c
   gnunet/src/fs/gnunet-service-fs_indexing.c
   gnunet/src/include/gnunet_disk_lib.h
   gnunet/src/nat/libnatpmp/getgateway.c
   gnunet/src/topology/gnunet-daemon-topology.c
   gnunet/src/transport/transport_api_blacklist.c
   gnunet/src/util/common_logging.c
   gnunet/src/util/configuration.c
   gnunet/src/util/container_bloomfilter.c
   gnunet/src/util/crypto_rsa.c
   gnunet/src/util/disk.c
   gnunet/src/util/getopt.c
   gnunet/src/util/os_installation.c
Log:
fixes

Modified: gnunet/src/fs/fs.c
===================================================================
--- gnunet/src/fs/fs.c  2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/fs/fs.c  2010-06-17 21:12:09 UTC (rev 11792)
@@ -583,11 +583,14 @@
       return;
     }
   filename = get_serialization_file_name (h, ext, ent);
-  if (0 != UNLINK (filename))
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                             "unlink", 
-                             filename);
-  GNUNET_free (filename);
+  if (filename != NULL)
+    {
+      if (0 != UNLINK (filename))
+       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                                 "unlink", 
+                                 filename);
+      GNUNET_free (filename);
+    }
 }
 
 
@@ -614,11 +617,14 @@
       return;
     }
   filename = get_serialization_file_name_in_dir (h, ext, uni, ent);
-  if (0 != UNLINK (filename))
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-                             "unlink", 
-                             filename);
-  GNUNET_free (filename);
+  if (filename != NULL)
+    {
+      if (0 != UNLINK (filename))
+       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                                 "unlink", 
+                                 filename);
+      GNUNET_free (filename);
+    }
 }
 
 
@@ -1030,6 +1036,8 @@
   if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
     return NULL; /* persistence not requested */
   dn = get_serialization_file_name (h, ext, "");
+  if (dn == NULL)
+    return NULL;
   if (GNUNET_OK !=
       GNUNET_DISK_directory_create_for_file (dn))
     {
@@ -1067,6 +1075,8 @@
   if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
     return NULL; /* persistence not requested */
   dn = get_serialization_file_name_in_dir (h, ext, uni, "");
+  if (dn == NULL)
+    return NULL;
   if (GNUNET_OK !=
       GNUNET_DISK_directory_create_for_file (dn))
     {
@@ -1282,9 +1292,12 @@
   GNUNET_free_non_null (chks);
   GNUNET_free_non_null (ksks);
   fn = get_serialization_file_name (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, 
fi->serialization);
-  if (0 != UNLINK (fn))
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
-  GNUNET_free (fn);
+  if (NULL != fn)
+    {
+      if (0 != UNLINK (fn))
+       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
+      GNUNET_free (fn);
+    }
   GNUNET_free (fi->serialization);
   fi->serialization = NULL;  
 }
@@ -1748,11 +1761,20 @@
        }
       fn = GNUNET_DISK_mktemp (dir);
       GNUNET_free (dir);
+      if (fn == NULL)
+       return;
       dc->serialization = get_serialization_short_name (fn);
     }
   else
     {
       fn = get_download_sync_filename (dc, dc->serialization, "");
+      if (fn == NULL)
+       {
+         GNUNET_free (dc->serialization);
+         dc->serialization = NULL;
+         GNUNET_free (fn);
+         return;
+       }
     }
   wh = GNUNET_BIO_write_open (fn);
   if (wh == NULL)
@@ -2226,19 +2248,22 @@
       drh = get_read_handle (sc->h, 
                             GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD,
                             download);
-      deserialize_download (sc->h,
-                           drh,
-                           NULL,
-                           sr,
-                           download);
-      if (GNUNET_OK !=
-         GNUNET_BIO_read_close (drh, &emsg))
+      if (drh != NULL)
        {
-         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                     _("Failed to resume sub-download `%s': %s\n"),
-                     download,
-                     emsg);
-         GNUNET_free (emsg);
+         deserialize_download (sc->h,
+                               drh,
+                               NULL,
+                               sr,
+                               download);
+         if (GNUNET_OK !=
+             GNUNET_BIO_read_close (drh, &emsg))
+           {
+             GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                         _("Failed to resume sub-download `%s': %s\n"),
+                         download,
+                         emsg);
+             GNUNET_free (emsg);
+           }
        }
       GNUNET_free (download);
     }
@@ -2247,18 +2272,21 @@
       drh = get_read_handle (sc->h, 
                             GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
                             update_srch);
-      deserialize_search (sc->h,
-                         drh,
-                         sr,
-                         update_srch);
-      if (GNUNET_OK !=
-         GNUNET_BIO_read_close (drh, &emsg))
+      if (drh != NULL)
        {
-         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                     _("Failed to resume sub-search `%s': %s\n"),
-                     update_srch,
-                     emsg);
-         GNUNET_free (emsg);
+         deserialize_search (sc->h,
+                             drh,
+                             sr,
+                             update_srch);
+         if (GNUNET_OK !=
+             GNUNET_BIO_read_close (drh, &emsg))
+           {
+             GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                         _("Failed to resume sub-search `%s': %s\n"),
+                         update_srch,
+                         emsg);
+             GNUNET_free (emsg);
+           }
        }
       GNUNET_free (update_srch);      
     }
@@ -2821,7 +2849,8 @@
       return GNUNET_OK;
     }
   sc = deserialize_search (h, rh, NULL, ser);
-  sc->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, sc);
+  if (sc != NULL)
+    sc->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, sc);
   GNUNET_free (ser);
   if (GNUNET_OK !=
       GNUNET_BIO_read_close (rh, &emsg))

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/fs/fs_download.c 2010-06-17 21:12:09 UTC (rev 11792)
@@ -1647,7 +1647,7 @@
   struct GNUNET_FS_ProgressInfo pi;
   struct GNUNET_FS_DownloadContext *dc;
 
-  if ( (sr != NULL) &&
+  if ( (sr == NULL) ||
        (sr->download != NULL) )
     {
       GNUNET_break (0);

Modified: gnunet/src/fs/fs_namespace.c
===================================================================
--- gnunet/src/fs/fs_namespace.c        2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/fs/fs_namespace.c        2010-06-17 21:12:09 UTC (rev 11792)
@@ -213,6 +213,7 @@
                                        &ac->nb->ns_purpose,
                                        &ac->nb->ns_signature));
   pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key);
+  GNUNET_assert (pk != NULL);
   GNUNET_CRYPTO_rsa_key_get_public (pk, &ac->nb->keyspace);
   GNUNET_CRYPTO_hash (&ac->nb->keyspace,
                      sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),

Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c  2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/fs/fs_publish.c  2010-06-17 21:12:09 UTC (rev 11792)
@@ -725,6 +725,7 @@
       return;
     }
   fn = GNUNET_STRINGS_filename_expand (p->filename);
+  GNUNET_assert (fn != NULL);
   slen = strlen (fn) + 1;
   if (slen > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof(struct IndexStartMessage))
     {
@@ -1369,6 +1370,7 @@
                             &iv,
                             &pkc->cpy[1]);
   pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key);
+  GNUNET_assert (NULL != pk);
   GNUNET_CRYPTO_rsa_key_get_public (pk, &pkc->cpy->keyspace);
   GNUNET_CRYPTO_hash (&pkc->cpy->keyspace,
                      sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),

Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c   2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/fs/fs_search.c   2010-06-17 21:12:09 UTC (rev 11792)
@@ -1149,6 +1149,7 @@
          keyword = &sc->uri->data.ksk.keywords[i][1];
          GNUNET_CRYPTO_hash (keyword, strlen (keyword), &hc);
          pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&hc);
+         GNUNET_assert (pk != NULL);
          GNUNET_CRYPTO_rsa_key_get_public (pk, &pub);
          GNUNET_CRYPTO_rsa_key_free (pk);
          GNUNET_CRYPTO_hash (&pub,
@@ -1335,6 +1336,8 @@
 {
   struct GNUNET_FS_SearchContext *ret;
   ret = search_start (h, uri, anonymity, options, cctx, NULL);
+  if (ret == NULL)
+    return NULL;
   ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, ret);
   return ret;
 }

Modified: gnunet/src/fs/fs_unindex.c
===================================================================
--- gnunet/src/fs/fs_unindex.c  2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/fs/fs_unindex.c  2010-06-17 21:12:09 UTC (rev 11792)
@@ -307,6 +307,14 @@
   uc->client = GNUNET_CLIENT_connect (uc->h->sched,
                                      "fs",
                                      uc->h->cfg);
+  if (uc->client == NULL)
+    {
+      uc->state = UNINDEX_STATE_ERROR;
+      uc->emsg = GNUNET_strdup (_("Failed to connect to FS service for 
unindexing."));
+      GNUNET_FS_unindex_sync_ (uc);
+      signal_unindex_error (uc);
+      return;
+    }
   req.header.size = htons (sizeof (struct UnindexMessage));
   req.header.type = htons (GNUNET_MESSAGE_TYPE_FS_UNINDEX);
   req.reserved = 0;

Modified: gnunet/src/fs/gnunet-search.c
===================================================================
--- gnunet/src/fs/gnunet-search.c       2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/fs/gnunet-search.c       2010-06-17 21:12:09 UTC (rev 11792)
@@ -263,7 +263,6 @@
               _("Could not initialize `%s' subsystem.\n"),
               "FS");
       GNUNET_FS_uri_destroy (uri);
-      GNUNET_FS_stop (ctx);
       ret = 1;
       return;
     }

Modified: gnunet/src/fs/gnunet-service-fs_indexing.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_indexing.c  2010-06-17 19:31:42 UTC (rev 
11791)
+++ gnunet/src/fs/gnunet-service-fs_indexing.c  2010-06-17 21:12:09 UTC (rev 
11792)
@@ -358,6 +358,12 @@
     }
   ism = (const struct IndexStartMessage*) message;
   fn = GNUNET_STRINGS_filename_expand ((const char*) &ism[1]);
+  if (fn == NULL)
+    {
+      GNUNET_SERVER_receive_done (client,
+                                 GNUNET_SYSERR);
+      return;
+    }
   dev = ntohl (ism->device);
   ino = GNUNET_ntohll (ism->inode);
   ism = (const struct IndexStartMessage*) message;

Modified: gnunet/src/include/gnunet_disk_lib.h
===================================================================
--- gnunet/src/include/gnunet_disk_lib.h        2010-06-17 19:31:42 UTC (rev 
11791)
+++ gnunet/src/include/gnunet_disk_lib.h        2010-06-17 21:12:09 UTC (rev 
11792)
@@ -458,7 +458,8 @@
  *
  * @param cls closure
  * @param di argument to pass to "GNUNET_DISK_directory_iterator_next" to
- *           get called on the next entry (or finish cleanly)
+ *           get called on the next entry (or finish cleanly);
+ *           NULL on error (will be the last call in that case)
  * @param filename complete filename (absolute path)
  * @param dirname directory name (absolute path)
  */

Modified: gnunet/src/nat/libnatpmp/getgateway.c
===================================================================
--- gnunet/src/nat/libnatpmp/getgateway.c       2010-06-17 19:31:42 UTC (rev 
11791)
+++ gnunet/src/nat/libnatpmp/getgateway.c       2010-06-17 21:12:09 UTC (rev 
11792)
@@ -105,9 +105,9 @@
       if (line > 0)
         {
           p = buf;
-          while (*p && !isspace (*p))
+          while (*p && !isspace ( (unsigned char) *p))
             p++;
-          while (*p && isspace (*p))
+          while (*p && isspace ( (unsigned char) *p))
             p++;
           for (i = 0; i < 16; i++)
             {

Modified: gnunet/src/topology/gnunet-daemon-topology.c
===================================================================
--- gnunet/src/topology/gnunet-daemon-topology.c        2010-06-17 19:31:42 UTC 
(rev 11791)
+++ gnunet/src/topology/gnunet-daemon-topology.c        2010-06-17 21:12:09 UTC 
(rev 11792)
@@ -1089,6 +1089,13 @@
       return;
     }
   data = GNUNET_malloc_large (frstat.st_size);
+  if (data == NULL)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                 _("Failed to read friends list from `%s': out of memory\n"), 
fn);
+      GNUNET_free (fn);
+      return;
+    }
   if (frstat.st_size !=
       GNUNET_DISK_fn_read (fn, data, frstat.st_size))
     {

Modified: gnunet/src/transport/transport_api_blacklist.c
===================================================================
--- gnunet/src/transport/transport_api_blacklist.c      2010-06-17 19:31:42 UTC 
(rev 11791)
+++ gnunet/src/transport/transport_api_blacklist.c      2010-06-17 21:12:09 UTC 
(rev 11792)
@@ -178,6 +178,7 @@
   br->client = GNUNET_CLIENT_connect (br->sched,
                                      "transport",
                                      br->cfg);
+  GNUNET_assert (br->client != NULL);
   br->th = GNUNET_CLIENT_notify_transmit_ready (br->client,
                                                sizeof (struct 
GNUNET_MessageHeader),
                                                GNUNET_TIME_UNIT_FOREVER_REL,

Modified: gnunet/src/util/common_logging.c
===================================================================
--- gnunet/src/util/common_logging.c    2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/util/common_logging.c    2010-06-17 21:12:09 UTC (rev 11792)
@@ -180,6 +180,8 @@
   if (logfile == NULL)
     return GNUNET_OK;
   fn = GNUNET_STRINGS_filename_expand (logfile);
+  if (NULL == fn)    
+    return GNUNET_SYSERR;    
   dirwarn = (GNUNET_OK !=  GNUNET_DISK_directory_create_for_file (fn));
   altlog = FOPEN (fn, "a");
   if (altlog == NULL)
@@ -374,7 +376,10 @@
   time (&timetmp);
   memset (date, 0, DATE_STR_SIZE);
   tmptr = localtime (&timetmp);
-  strftime (date, DATE_STR_SIZE, "%b %d %H:%M:%S", tmptr);
+  if (NULL != tmptr)
+    strftime (date, DATE_STR_SIZE, "%b %d %H:%M:%S", tmptr);
+  else
+    strcpy (date, "localtime error");
   if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) &&
       (last_bulk_time.value != 0) &&
       (0 == strncmp (buf, last_bulk, sizeof (last_bulk))))

Modified: gnunet/src/util/configuration.c
===================================================================
--- gnunet/src/util/configuration.c     2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/util/configuration.c     2010-06-17 21:12:09 UTC (rev 11792)
@@ -176,6 +176,8 @@
   char *fn;
 
   fn = GNUNET_STRINGS_filename_expand (filename);
+  if (fn == NULL)
+    return GNUNET_SYSERR;
   dirty = cfg->dirty;           /* back up value! */
   if (NULL == (fp = FOPEN (fn, "r")))
     {
@@ -302,6 +304,8 @@
   char *pos;
 
   fn = GNUNET_STRINGS_filename_expand (filename);
+  if (fn == NULL)
+    return GNUNET_SYSERR;
   GNUNET_DISK_directory_create_for_file (fn);
   if (NULL == (fp = FOPEN (fn, "w")))
     {

Modified: gnunet/src/util/container_bloomfilter.c
===================================================================
--- gnunet/src/util/container_bloomfilter.c     2010-06-17 19:31:42 UTC (rev 
11791)
+++ gnunet/src/util/container_bloomfilter.c     2010-06-17 21:12:09 UTC (rev 
11792)
@@ -433,6 +433,14 @@
     }
   /* Alloc block */
   bf->bitArray = GNUNET_malloc_large (size);
+  if (bf->bitArray == NULL)
+    {
+      if (bf->fh != NULL)
+       GNUNET_DISK_file_close (bf->fh);
+      GNUNET_free_non_null (bf->filename);
+      GNUNET_free (bf);
+      return NULL;
+    }
   bf->bitArraySize = size;
   bf->addressesPerElement = k;
   memset (bf->bitArray, 0, bf->bitArraySize);
@@ -505,6 +513,11 @@
   bf->filename = NULL;
   bf->fh = NULL;
   bf->bitArray = GNUNET_malloc_large (size);
+  if (bf->bitArray == NULL)
+    {
+      GNUNET_free (bf);
+      return NULL;
+    }
   bf->bitArraySize = size;
   bf->addressesPerElement = k;
   if (data != NULL)

Modified: gnunet/src/util/crypto_rsa.c
===================================================================
--- gnunet/src/util/crypto_rsa.c        2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/util/crypto_rsa.c        2010-06-17 21:12:09 UTC (rev 11792)
@@ -779,6 +779,8 @@
 
   GNUNET_assert (size <= sizeof (GNUNET_HashCode));
   pubkey = public2PrivateKey (publicKey);
+  if (pubkey == NULL)
+    return GNUNET_SYSERR;
   isize = size;
   GNUNET_assert (0 ==
                  gcry_mpi_scan (&val, GCRYMPI_FMT_USG, block, isize, &isize));

Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c      2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/util/disk.c      2010-06-17 21:12:09 UTC (rev 11792)
@@ -346,6 +346,8 @@
   char *path;
 
   path = GNUNET_STRINGS_filename_expand (part);
+  if (path == NULL)
+    return -1;
   memcpy (szDrive, path, 3);
   GNUNET_free (path);
   szDrive[3] = 0;
@@ -904,6 +906,12 @@
   di->callback = callback;
   di->callback_cls = callback_cls;
   di->directory = OPENDIR (dirName);
+  if (di->directory == NULL)
+    {
+      GNUNET_free (di);
+      callback (callback_cls, NULL, NULL, NULL);
+      return;
+    }
   di->dirname = GNUNET_strdup (dirName);
   di->priority = prio;
   GNUNET_DISK_directory_iterator_next (di, GNUNET_NO);

Modified: gnunet/src/util/getopt.c
===================================================================
--- gnunet/src/util/getopt.c    2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/util/getopt.c    2010-06-17 21:12:09 UTC (rev 11792)
@@ -847,6 +847,7 @@
 
         /* Test all long options for either exact match
            or abbreviated matches.  */
+       if (longopts != NULL)
         for (p = longopts, option_index = 0; p->name; p++, option_index++)
           if (!strncmp (p->name, nextchar, nameend - nextchar))
             {

Modified: gnunet/src/util/os_installation.c
===================================================================
--- gnunet/src/util/os_installation.c   2010-06-17 19:31:42 UTC (rev 11791)
+++ gnunet/src/util/os_installation.c   2010-06-17 21:12:09 UTC (rev 11792)
@@ -55,32 +55,31 @@
 get_path_from_proc_maps ()
 {
   char fn[64];
-  char *line;
-  char *dir;
+  char line[1024];
+  char dir[1024];
   FILE *f;
+  char *lgu;
 
-  GNUNET_snprintf (fn, 64, "/proc/%u/maps", getpid ());
-  line = GNUNET_malloc (1024);
-  dir = GNUNET_malloc (1024);
+  GNUNET_snprintf (fn,
+                  sizeof(fn), 
+                  "/proc/%u/maps", 
+                  getpid ());
   f = fopen (fn, "r");
-  if (f != NULL)
+  if (f == NULL)
+    return NULL;
+  while (NULL != fgets (line, sizeof(line), f))
     {
-      while (NULL != fgets (line, 1024, f))
-        {
-          if ((1 == sscanf (line,
-                            "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s",
-                            dir)) && (NULL != strstr (dir, "libgnunetutil")))
-            {
-              strstr (dir, "libgnunetutil")[0] = '\0';
-              fclose (f);
-              GNUNET_free (line);
-              return dir;
-            }
-        }
-      fclose (f);
+      if ((1 == sscanf (line,
+                       "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s",
+                       dir)) &&
+         (NULL != (lgu = strstr (dir, "libgnunetutil"))))
+       {
+         lgu[0] = '\0';
+         fclose (f);
+         return GNUNET_strdup (dir);
+       }
     }
-  GNUNET_free (dir);
-  GNUNET_free (line);
+  fclose (f);
   return NULL;
 }
 
@@ -91,13 +90,13 @@
 get_path_from_proc_exe ()
 {
   char fn[64];
-  char *lnk;
-  size_t size;
+  char lnk[1024];
+  ssize_t size;
 
-  GNUNET_snprintf (fn, 64, "/proc/%u/exe", getpid ());
-  lnk = GNUNET_malloc (1024);
-  size = readlink (fn, lnk, 1023);
-  if ((size == 0) || (size >= 1024))
+  GNUNET_snprintf (fn, 
+                  sizeof(fn), "/proc/%u/exe", getpid ());
+  size = readlink (fn, lnk, sizeof (lnk)-1);
+  if ((size == 0) || (size >= sizeof(lnk)-1))
     {
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "readlink", fn);
       GNUNET_free (lnk);
@@ -113,7 +112,7 @@
       return NULL;
     }
   lnk[size] = '\0';
-  return lnk;
+  return GNUNET_strdup (lnk);
 }
 #endif
 
@@ -124,16 +123,15 @@
 static char *
 get_path_from_module_filename ()
 {
-  char *path;
+  char path[4097];
   char *idx;
 
-  path = GNUNET_malloc (4097);
-  GetModuleFileName (NULL, path, 4096);
+  GetModuleFileName (NULL, path, sizeof(path)-1);
   idx = path + strlen (path);
   while ((idx > path) && (*idx != '\\') && (*idx != '/'))
     idx--;
   *idx = '\0';
-  return path;
+  return GNUNET_strdup (path);
 }
 #endif
 




reply via email to

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