[systemd-commits] 2 commits - src/journal

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Mon Mar 17 21:03:33 PDT 2014


 src/journal/journal-remote-parse.c |    8 ++++++++
 src/journal/microhttpd-util.c      |   14 ++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)

New commits:
commit 4dd5da7f7d37f964fe95b0f0d451d7843a34591d
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Mar 17 22:13:47 2014 -0400

    microhttpd-util: avoid double free on error
    
    It seems that resources are properly deallocated by MHD_destroy_response,
    even if enqueuing the request fails.
    
    Also replace a trivial printf with alloca and fixup log message
    (it'll now be something like "Connection from CN=some.host.name",
    which seems clear enough.)

diff --git a/src/journal/microhttpd-util.c b/src/journal/microhttpd-util.c
index 250be93..f693e0f 100644
--- a/src/journal/microhttpd-util.c
+++ b/src/journal/microhttpd-util.c
@@ -35,12 +35,9 @@
 #endif
 
 void microhttpd_logger(void *arg, const char *fmt, va_list ap) {
-        _cleanup_free_ char *f = NULL;
+        char *f;
 
-        if (asprintf(&f, "microhttpd: %s", fmt) <= 0) {
-                log_oom();
-                return;
-        }
+        f = strappenda("microhttpd: ", fmt);
 
         DISABLE_WARNING_FORMAT_NONLITERAL;
         log_metav(LOG_INFO, NULL, 0, NULL, f, ap);
@@ -101,10 +98,7 @@ int mhd_respondf(struct MHD_Connection *connection,
         if (r < 0)
                 return respond_oom(connection);
 
-        r = mhd_respond_internal(connection, code, m, r, MHD_RESPMEM_MUST_FREE);
-        if (r == MHD_NO)
-                free(m);
-        return r;
+        return mhd_respond_internal(connection, code, m, r, MHD_RESPMEM_MUST_FREE);
 }
 
 #ifdef HAVE_GNUTLS
@@ -256,7 +250,7 @@ int check_permissions(struct MHD_Connection *connection, int *code) {
                 return -EPERM;
         }
 
-        log_info("Connection from DN %s", buf);
+        log_info("Connection from %s", buf);
 
         r = verify_cert_authorized(session);
         if (r < 0) {

commit 9786767a36803f6a27870e6f2a666113565e19d2
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Mar 17 22:11:18 2014 -0400

    journal-remote: do not attempt to read from µhttpd connections
    
    This chunk got lost in one of the rebases :(

diff --git a/src/journal/journal-remote-parse.c b/src/journal/journal-remote-parse.c
index c961844..142de0e 100644
--- a/src/journal/journal-remote-parse.c
+++ b/src/journal/journal-remote-parse.c
@@ -54,6 +54,10 @@ static int get_line(RemoteSource *source, char **line, size_t *size) {
                 goto docopy;
 
  resize:
+        if (source->fd < 0)
+                /* we have to wait for some data to come to us */
+                return -EWOULDBLOCK;
+
         if (source->size - source->filled < LINE_CHUNK) {
                 // XXX: add check for maximum line length
 
@@ -130,6 +134,10 @@ static int fill_fixed_size(RemoteSource *source, void **data, size_t size) {
         assert(data);
 
         while(source->filled < size) {
+                if (source->fd < 0)
+                        /* we have to wait for some data to come to us */
+                        return -EWOULDBLOCK;
+
                 if (!GREEDY_REALLOC(source->buf, source->size, size))
                         return log_oom();
 



More information about the systemd-commits mailing list