ARMmbed / ARMmbed/ATParser

Accessing a negative index

Open
#12 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39
Forks
24
PR merge metrics
No merged PRs in 30d

Description

I read following code and found next line is accessing a negative index. Is it true?
`response[i+1-_recv_delim_size]`
I assume following conditions.
i=0, recv_delim_size=2, recv_delimiter="\r\n"

```
bool ATParser::vrecv(const char *response, va_list args)

int i = 0;
int offset = 0;

while (response[i]) {
if (memcmp(&response[i+1-_recv_delim_size], _recv_delimiter, _recv_delim_size) == 0) {
i++;
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in ATParser::vrecv at the response[i+1-_recv_delim_size] expression and inspect the loop with i=0, recv_delim_size=2, and the "\r\n" delimiter. Check whether the referenced memory is valid before memcmp and determine what behavior or test should confirm the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.