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

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