# HG changeset patch # User Alain Mazy # Date 1638446427 -3600 # Node ID a678ff1b827853aad54a03bca6b6bb16acf99ea1 # Parent 6c276fac0cc024d98f2120e2cd1c067141e98efd CPP Wrapper: fail when trying to use body > 4GB diff -r 6c276fac0cc0 -r a678ff1b8278 OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp --- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Thu Nov 25 15:36:11 2021 +0100 +++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Thu Dec 02 13:00:27 2021 +0100 @@ -539,6 +539,13 @@ const std::string& password) { Clear(); + + if (body.size() > 0xffffffffu) + { + LogError("Cannot handle body size > 4GB"); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); + } + return CheckHttp(OrthancPluginHttpPost(GetGlobalContext(), &buffer_, url.c_str(), body.c_str(), body.size(), username.empty() ? NULL : username.c_str(), @@ -552,6 +559,13 @@ const std::string& password) { Clear(); + + if (body.size() > 0xffffffffu) + { + LogError("Cannot handle body size > 4GB"); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); + } + return CheckHttp(OrthancPluginHttpPut(GetGlobalContext(), &buffer_, url.c_str(), body.empty() ? NULL : body.c_str(), body.size(), @@ -1892,6 +1906,12 @@ ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); } + if (body.size() > 0xffffffffu) + { + LogError("Cannot handle body size > 4GB"); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); + } + OrthancPlugins::MemoryBuffer answer; uint16_t status; OrthancPluginErrorCode code = OrthancPluginCallPeerApi @@ -1920,6 +1940,12 @@ ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); } + if (body.size() > 0xffffffffu) + { + LogError("Cannot handle body size > 4GB"); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); + } + OrthancPlugins::MemoryBuffer answer; uint16_t status; OrthancPluginErrorCode code = OrthancPluginCallPeerApi @@ -2883,6 +2909,12 @@ MemoryBuffer answerBodyBuffer, answerHeadersBuffer; + if (body.size() > 0xffffffffu) + { + LogError("Cannot handle body size > 4GB"); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); + } + OrthancPluginErrorCode error = OrthancPluginHttpClient( GetGlobalContext(), *answerBodyBuffer, diff -r 6c276fac0cc0 -r a678ff1b8278 TODO --- a/TODO Thu Nov 25 15:36:11 2021 +0100 +++ b/TODO Thu Dec 02 13:00:27 2021 +0100 @@ -167,6 +167,7 @@ https://groups.google.com/d/msg/orthanc-users/BtvLTE5Ni8A/vIMhmMgfBAAJ * In "OrthancPluginLog[Error|Warning|Info]()", prefix the log line with the name of the plugin, as retrieved by "OrthancPluginGetName()" +* update the SDK to handle buffer sizes > 4GB (all sizes are currently coded in uint32_t) ---------------- Ideas of plugins