return OC_STACK_INVALID_PARAM;
}
+ if (headerOptions.size() > MAX_HEADER_OPTIONS)
+ {
+ oclog() << "ListenForMQTopic: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+ return OC_STACK_INVALID_PARAM;
+ }
+
ClientCallbackContext::MQTopicContext* context =
new ClientCallbackContext::MQTopicContext(callback, shared_from_this());
OCCallbackData cbdata;
if (cLock)
{
std::lock_guard<std::recursive_mutex> lock(*cLock);
- OCHeaderOption options[MAX_HEADER_OPTIONS];
+ OCHeaderOption *options = assembleHeaderOptions(headerOptions);
result = OCDoResource(
nullptr, OC_REST_GET,
uri.c_str(),
CT_DEFAULT,
static_cast<OCQualityOfService>(QoS),
&cbdata,
- assembleHeaderOptions(options, headerOptions),
+ options,
headerOptions.size());
+ delete[] options;
}
else
{
{
return OC_STACK_INVALID_PARAM;
}
+
+ if (headerOptions.size() > MAX_HEADER_OPTIONS)
+ {
+ oclog() << "PutMQTopicRepresentation: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+ return OC_STACK_INVALID_PARAM;
+ }
+
OCStackResult result;
ClientCallbackContext::MQTopicContext* ctx =
new ClientCallbackContext::MQTopicContext(callback, shared_from_this());
if (cLock)
{
std::lock_guard<std::recursive_mutex> lock(*cLock);
- OCHeaderOption options[MAX_HEADER_OPTIONS];
+ OCHeaderOption *options = assembleHeaderOptions(headerOptions);
result = OCDoResource(nullptr, OC_REST_PUT,
url.c_str(), &devAddr,
CT_DEFAULT,
static_cast<OCQualityOfService>(QoS),
&cbdata,
- assembleHeaderOptions(options, headerOptions),
+ options,
headerOptions.size());
+ delete[] options;
}
else
{
{
return OC_STACK_INVALID_PARAM;
}
+
+ if (headerOptions.size() > MAX_HEADER_OPTIONS)
+ {
+ oclog() << "GetResourceRepresentation: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+ return OC_STACK_INVALID_PARAM;
+ }
+
OCStackResult result;
ClientCallbackContext::GetContext* ctx =
new ClientCallbackContext::GetContext(callback);
if (cLock)
{
std::lock_guard<std::recursive_mutex> lock(*cLock);
- OCHeaderOption options[MAX_HEADER_OPTIONS];
+ OCHeaderOption *options = assembleHeaderOptions(headerOptions);
result = OCDoResource(
nullptr, OC_REST_GET,
connectivityType,
static_cast<OCQualityOfService>(QoS),
&cbdata,
- assembleHeaderOptions(options, headerOptions),
+ options,
headerOptions.size());
+ delete[] options;
}
else
{
{
return OC_STACK_INVALID_PARAM;
}
+
+ if (headerOptions.size() > MAX_HEADER_OPTIONS)
+ {
+ oclog() << "PostResourceRepresentation: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+ return OC_STACK_INVALID_PARAM;
+ }
+
OCStackResult result;
ClientCallbackContext::SetContext* ctx = new ClientCallbackContext::SetContext(callback);
OCCallbackData cbdata;
if (cLock)
{
std::lock_guard<std::recursive_mutex> lock(*cLock);
- OCHeaderOption options[MAX_HEADER_OPTIONS];
+ OCHeaderOption *options = assembleHeaderOptions(headerOptions);
result = OCDoResource(nullptr, OC_REST_POST,
url.c_str(), &devAddr,
connectivityType,
static_cast<OCQualityOfService>(QoS),
&cbdata,
- assembleHeaderOptions(options, headerOptions),
+ options,
headerOptions.size());
+ delete[] options;
}
else
{
{
return OC_STACK_INVALID_PARAM;
}
+
+ if (headerOptions.size() > MAX_HEADER_OPTIONS)
+ {
+ oclog() << "PutResourceRepresentation: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+ return OC_STACK_INVALID_PARAM;
+ }
+
OCStackResult result;
ClientCallbackContext::SetContext* ctx = new ClientCallbackContext::SetContext(callback);
OCCallbackData cbdata;
{
std::lock_guard<std::recursive_mutex> lock(*cLock);
OCDoHandle handle;
- OCHeaderOption options[MAX_HEADER_OPTIONS];
+ OCHeaderOption *options = assembleHeaderOptions(headerOptions);
result = OCDoResource(&handle, OC_REST_PUT,
url.c_str(), &devAddr,
CT_DEFAULT,
static_cast<OCQualityOfService>(QoS),
&cbdata,
- assembleHeaderOptions(options, headerOptions),
+ options,
headerOptions.size());
+ delete[] options;
}
else
{
{
return OC_STACK_INVALID_PARAM;
}
+
+ if (headerOptions.size() > MAX_HEADER_OPTIONS)
+ {
+ oclog() << "DeleteResource: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+ return OC_STACK_INVALID_PARAM;
+ }
+
OCStackResult result;
ClientCallbackContext::DeleteContext* ctx =
new ClientCallbackContext::DeleteContext(callback);
if (cLock)
{
- OCHeaderOption options[MAX_HEADER_OPTIONS];
+ OCHeaderOption *options = assembleHeaderOptions(headerOptions);
std::lock_guard<std::recursive_mutex> lock(*cLock);
connectivityType,
static_cast<OCQualityOfService>(m_cfg.QoS),
&cbdata,
- assembleHeaderOptions(options, headerOptions),
+ options,
headerOptions.size());
+ delete[] options;
}
else
{
{
return OC_STACK_INVALID_PARAM;
}
+
+ if (headerOptions.size() > MAX_HEADER_OPTIONS)
+ {
+ oclog() << "ObserveResource: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+ return OC_STACK_INVALID_PARAM;
+ }
+
OCStackResult result;
ClientCallbackContext::ObserveContext* ctx =
if (cLock)
{
std::lock_guard<std::recursive_mutex> lock(*cLock);
- OCHeaderOption options[MAX_HEADER_OPTIONS];
+ OCHeaderOption *options = assembleHeaderOptions(headerOptions);
result = OCDoResource(handle, method,
url.c_str(), &devAddr,
CT_DEFAULT,
static_cast<OCQualityOfService>(QoS),
&cbdata,
- assembleHeaderOptions(options, headerOptions),
+ options,
headerOptions.size());
+ delete[] options;
}
else
{
const HeaderOptions& headerOptions,
QualityOfService QoS)
{
+ if (headerOptions.size() > MAX_HEADER_OPTIONS)
+ {
+ oclog() << "CancelObserveResource: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+ return OC_STACK_INVALID_PARAM;
+ }
+
OCStackResult result;
auto cLock = m_csdkLock.lock();
if (cLock)
{
std::lock_guard<std::recursive_mutex> lock(*cLock);
- OCHeaderOption options[MAX_HEADER_OPTIONS];
+ OCHeaderOption *options = assembleHeaderOptions(headerOptions);
result = OCCancel(handle,
static_cast<OCQualityOfService>(QoS),
- assembleHeaderOptions(options, headerOptions),
+ options,
headerOptions.size());
+ delete[] options;
}
else
{
return OC_STACK_OK;
}
- OCHeaderOption* InProcClientWrapper::assembleHeaderOptions(OCHeaderOption options[],
- const HeaderOptions& headerOptions)
+ OCHeaderOption* InProcClientWrapper::assembleHeaderOptions(const HeaderOptions& headerOptions)
{
- int i = 0;
-
if ( headerOptions.size() == 0)
{
return nullptr;
}
+ OCHeaderOption* options = new OCHeaderOption[headerOptions.size()];
+ int i = 0;
for (auto it=headerOptions.begin(); it != headerOptions.end(); ++it)
{
options[i] = OCHeaderOption();