[grilo] net: Sanitize GRL_WEB_CAPTURE_DIR handling



commit 93d7a8730c5f321ad5ef7b9471997368b4b12eec
Author: Mathias Hasselmann <mathias openismus com>
Date:   Thu Oct 11 20:48:53 2012 +0200

    net: Sanitize GRL_WEB_CAPTURE_DIR handling

 libs/net/grl-net-private.c |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)
---
diff --git a/libs/net/grl-net-private.c b/libs/net/grl-net-private.c
index 401c913..a030905 100644
--- a/libs/net/grl-net-private.c
+++ b/libs/net/grl-net-private.c
@@ -29,6 +29,8 @@
 
 #include "grl-net-private.h"
 
+static const char *capture_dir = NULL;
+
 void
 parse_error (guint status,
              const gchar *reason,
@@ -93,13 +95,10 @@ parse_error (guint status,
 void
 init_dump_directory ()
 {
-  const char *path;
-
-  path = g_getenv ("GRL_WEB_CAPTURE_DIR");
-  if (!path)
-    return;
+  capture_dir = g_getenv ("GRL_WEB_CAPTURE_DIR");
 
-  g_mkdir_with_parents (path, 0700);
+  if (capture_dir && g_mkdir_with_parents (capture_dir, 0700))
+    capture_dir = NULL;
 }
 
 void
@@ -107,12 +106,9 @@ dump_data (SoupURI *soup_uri,
            const char *buffer,
            const gsize length)
 {
-  const char *capture_dir;
   char *uri, *escaped_uri, *file;
   GError *error = NULL;
 
-  capture_dir = g_getenv ("GRL_WEB_CAPTURE_DIR");
-
   if (!capture_dir)
     return;
 



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