From 382a6ea386f8ef2e5c131f7c65f7b041beb328c8 Mon Sep 17 00:00:00 2001 From: Konrad Lipinski Date: Tue, 24 Sep 2019 14:40:58 +0200 Subject: [PATCH] [ocsp] Fix static string length calculation Change-Id: I13d6c6f825a9340bfd54462d7d6c9cbd46008dd2 --- src/manager/service/ocsp.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/manager/service/ocsp.cpp b/src/manager/service/ocsp.cpp index 60cdb5b..c6cb2fd 100644 --- a/src/manager/service/ocsp.cpp +++ b/src/manager/service/ocsp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 - 2019 Samsung Electronics Co. + * Copyright (c) 2014-2019 Samsung Electronics Co., Ltd. All rights reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,10 +45,16 @@ namespace CKM { namespace { -const char *const HTTP_PREFIX = "http://"; -const size_t HTTP_PREFIX_LEN = sizeof(HTTP_PREFIX) / sizeof(HTTP_PREFIX[0]); -const char *const HTTPS_PREFIX = "https://"; -const size_t HTTPS_PREFIX_LEN = sizeof(HTTPS_PREFIX) / sizeof(HTTPS_PREFIX[0]); +template +constexpr size_t staticStringLen(const char (&)[S]) { + static_assert(S, "static string of zero size"); + return S-1; +} + +const char HTTP_PREFIX[] = "http://"; +const size_t HTTP_PREFIX_LEN = staticStringLen(HTTP_PREFIX); +const char HTTPS_PREFIX[] = "https://"; +const size_t HTTPS_PREFIX_LEN = staticStringLen(HTTPS_PREFIX); typedef std::unique_ptr> BioUniquePtr; -- 2.7.4