From 4371cb41d0ce8ddc2a23792cc29ea5da5666132d Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Mon, 27 Apr 2020 16:56:34 -0300 Subject: [PATCH] api/service: fix segfault when taking a snapshot without keyspace specified If no keyspace is specified when taking snapshot, there will be a segfault because keynames is unconditionally dereferenced. Let's return an error because a keyspace must be specified when column families are specified. Signed-off-by: Raphael S. Carvalho Message-Id: <20200427195634.99940-1-raphaelsc@scylladb.com> (cherry picked from commit 02e046608f82631d5bf7ebd1ce464630826e27d4) Fixes #6336. --- api/storage_service.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/storage_service.cc b/api/storage_service.cc index 98511de2ff..bd89a1f0b0 100644 --- a/api/storage_service.cc +++ b/api/storage_service.cc @@ -254,6 +254,9 @@ void set_storage_service(http_context& ctx, routes& r) { if (column_family.empty()) { resp = service::get_local_storage_service().take_snapshot(tag, keynames); } else { + if (keynames.empty()) { + throw httpd::bad_param_exception("The keyspace of column families must be specified"); + } if (keynames.size() > 1) { throw httpd::bad_param_exception("Only one keyspace allowed when specifying a column family"); }