gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: fix #5242 topology.txt writ


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: fix #5242 topology.txt write issue
Date: Fri, 12 Jan 2018 12:11:56 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 9428ea300 fix #5242 topology.txt write issue
9428ea300 is described below

commit 9428ea3004c5b90949cfb46174a2bcd7e76ac816
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Jan 12 12:11:53 2018 +0100

    fix #5242 topology.txt write issue
---
 src/topology/friends.c | 39 +++++++++++++++++++++++++++++----------
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/src/topology/friends.c b/src/topology/friends.c
index 65f2700bb..cdfedbc81 100644
--- a/src/topology/friends.c
+++ b/src/topology/friends.c
@@ -46,6 +46,7 @@ GNUNET_FRIENDS_parse (const struct 
GNUNET_CONFIGURATION_Handle *cfg,
   size_t start;
   struct GNUNET_PeerIdentity pid;
   uint64_t fsize;
+  ssize_t ssize;
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_filename (cfg,
@@ -57,13 +58,24 @@ GNUNET_FRIENDS_parse (const struct 
GNUNET_CONFIGURATION_Handle *cfg,
                               "topology", "FRIENDS");
     return GNUNET_SYSERR;
   }
-  if ( (GNUNET_OK != GNUNET_DISK_file_test (fn)) &&
-       (GNUNET_OK != GNUNET_DISK_fn_write (fn,
-                                           NULL,
-                                           0,
-                                          GNUNET_DISK_PERM_USER_READ |
-                                          GNUNET_DISK_PERM_USER_WRITE |
-                                           GNUNET_DISK_OPEN_CREATE)) )
+  if (GNUNET_SYSERR ==
+      GNUNET_DISK_directory_create_for_file (fn))
+  {
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+                              "mkdir",
+                              fn);
+    GNUNET_free (fn);
+    return GNUNET_SYSERR;
+  }
+  if ( (GNUNET_OK !=
+        GNUNET_DISK_file_test (fn)) &&
+       (GNUNET_OK !=
+        GNUNET_DISK_fn_write (fn,
+                              NULL,
+                              0,
+                              GNUNET_DISK_PERM_USER_READ |
+                              GNUNET_DISK_PERM_USER_WRITE |
+                              GNUNET_DISK_OPEN_CREATE)) )
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
                               "write",
                               fn);
@@ -84,9 +96,15 @@ GNUNET_FRIENDS_parse (const struct 
GNUNET_CONFIGURATION_Handle *cfg,
     GNUNET_free (fn);
     return GNUNET_SYSERR;
   }
-  if (fsize != GNUNET_DISK_fn_read (fn, data, fsize))
+  ssize = GNUNET_DISK_fn_read (fn,
+                               data,
+                               fsize);
+  if ( (ssize < 0) ||
+       (fsize != (uint64_t) ssize) )
   {
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "read", "fn");
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+                              "read",
+                              "fn");
     GNUNET_free (fn);
     GNUNET_free (data);
     return GNUNET_SYSERR;
@@ -95,7 +113,8 @@ GNUNET_FRIENDS_parse (const struct 
GNUNET_CONFIGURATION_Handle *cfg,
   pos = 0;
   while (pos < fsize)
   {
-    while ((pos < fsize) && (! isspace ((unsigned char) data[pos])))
+    while ( (pos < fsize) &&
+            (! isspace ((unsigned char) data[pos])) )
       pos++;
     if (GNUNET_OK !=
         GNUNET_CRYPTO_eddsa_public_key_from_string (&data[start],

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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