Skip to content

Commit

Permalink
Fix the check if there is really max size
Browse files Browse the repository at this point in the history
  • Loading branch information
amgross committed Dec 1, 2022
1 parent f1c4a23 commit 25022d7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions erpcgen/src/templates/c_coders.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
uint32_t {$info.stringLocalName}_len;
char * {$info.stringLocalName}_local;
codec->readString(&{$info.stringLocalName}_len, &{$info.stringLocalName}_local);
{% if info.stringAllocSize != info.stringLocalName + "_len" %}
{% if info.stringAllocSize != info.stringLocalName & "_len" %}
if ({$info.stringLocalName}_len <= {$info.stringAllocSize})
{
{% set indent = " " >%}
{% else %}
{% set indent = "" >%}
{% endif -- if info.stringAllocSize != info.stringLocalName + "_len" %}
{% endif -- if info.stringAllocSize != info.stringLocalName & "_len" %}
{% if ((source == "client" && info.withoutAlloc == false) or source == "server") %}
{$indent}{$info.name} = ({$info.builtinTypeName}) erpc_malloc(({$info.stringAllocSize} + 1) * sizeof(char));
{% if generateAllocErrorChecks == true %}
Expand All @@ -26,13 +26,13 @@ if ({$info.stringLocalName}_len <= {$info.stringAllocSize})
{% if (((source == "client" && info.withoutAlloc == false) or source == "server") && generateAllocErrorChecks == true) %}
{$indent}}
{% endif -- withoutAlloc && generateAllocErrorChecks %}
{% if info.stringAllocSize != info.stringLocalName + "_len" %}
{% if info.stringAllocSize != info.stringLocalName & "_len" %}
}
else
{
codec->updateStatus(kErpcStatus_InvalidArgument);
}
{% endif -- if info.stringAllocSize != info.stringLocalName + "_len" %}
{% endif -- if info.stringAllocSize != info.stringLocalName & "_len" %}
{% else %}
{% if source == "client" && info.pointerScalarTypes %}
codec->read({$info.name});
Expand Down Expand Up @@ -243,7 +243,7 @@ codec->readData({$info.name}, {$info.sizeTemp} * sizeof({$info.builtinTypeName})
{% def encodeBuiltinType(info) ----------------- %}
{% if info.builtinType == "kStringType" %}
uint32_t {$info.stringLocalName}_len = strlen((const char*){$info.name});
{% if info.stringAllocSize != info.stringLocalName + "_len" %}
{% if info.stringAllocSize != info.stringLocalName & "_len" %}

{% if source == "server" %}
erpc_assert({$info.stringLocalName}_len <= {$info.stringAllocSize});
Expand All @@ -269,7 +269,7 @@ codec->write({$info.name});
{% def encodeBinaryType(info) ----------------- %}
{% if info.size != info.maxSize %}
{% if source == "server" %}
erpc_assert({$info.size} <= {$info.maxSize} * sizeof({$info.mallocSizeType}));
erpc_assert({$info.sizeTemp} <= {$info.maxSize} * sizeof({$info.mallocSizeType}));

{% else %}
if ({% if info.pointerScalarTypes %}*{% endif %}{$info.size} > {$info.maxSize})
Expand Down

0 comments on commit 25022d7

Please sign in to comment.