Blame SOURCES/0030-SECRETS-Return-a-nicer-error-message-on-request-with.patch

bb7cd1
From ddda18a37ac4b732ad109dbb129255dc3edd8fbb Mon Sep 17 00:00:00 2001
bb7cd1
From: Jakub Hrozek <jhrozek@redhat.com>
bb7cd1
Date: Fri, 3 Feb 2017 14:33:47 +0100
bb7cd1
Subject: [PATCH 30/36] SECRETS: Return a nicer error message on request with
bb7cd1
 no PUT data
bb7cd1
MIME-Version: 1.0
bb7cd1
Content-Type: text/plain; charset=UTF-8
bb7cd1
Content-Transfer-Encoding: 8bit
bb7cd1
bb7cd1
I managed to create this pathological situation with the tcurl tool
bb7cd1
which didn't send any PUT data. The error in sssd-secrets was quite
bb7cd1
strange (ENOMEM). This patch just adds a safeguard sooner so that we
bb7cd1
return a graceful error.
bb7cd1
bb7cd1
Reviewed-by: Michal Židek <mzidek@redhat.com>
bb7cd1
Reviewed-by: Simo Sorce <simo@redhat.com>
bb7cd1
---
bb7cd1
 src/responder/secrets/local.c | 6 ++++++
bb7cd1
 1 file changed, 6 insertions(+)
bb7cd1
bb7cd1
diff --git a/src/responder/secrets/local.c b/src/responder/secrets/local.c
bb7cd1
index 9dcdd9925e542499d3a962b4998103b07c26a5ab..26c97a2849febbf0ac482d526cf927bfc103b4f2 100644
bb7cd1
--- a/src/responder/secrets/local.c
bb7cd1
+++ b/src/responder/secrets/local.c
bb7cd1
@@ -853,6 +853,12 @@ static struct tevent_req *local_secret_req(TALLOC_CTX *mem_ctx,
bb7cd1
         break;
bb7cd1
 
bb7cd1
     case HTTP_PUT:
bb7cd1
+        if (secreq->body.length == 0) {
bb7cd1
+            DEBUG(SSSDBG_OP_FAILURE, "PUT with no data\n");
bb7cd1
+            ret = EINVAL;
bb7cd1
+            goto done;
bb7cd1
+        }
bb7cd1
+
bb7cd1
         DEBUG(SSSDBG_TRACE_LIBS, "Processing HTTP PUT at [%s]\n", lc_req->path);
bb7cd1
         if (body_is_json) {
bb7cd1
             ret = sec_json_to_simple_secret(state, secreq->body.data,
bb7cd1
-- 
bb7cd1
2.9.3
bb7cd1