Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[iioadaptor] Improve strtol error handling. Contributes to MER#2076
  • Loading branch information
DylanVanAssche committed Jan 23, 2020
1 parent b49a908 commit 7074a07
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion adaptors/iioadaptor/iioadaptor.cpp
Expand Up @@ -434,10 +434,15 @@ void IioAdaptor::processSample(int fileId, int fd)
sensordLogW() << "read():" << strerror(errno);
return;
}

errno = 0; // reset errno before call
result = strtol(buf, NULL, 10);

if (result == 0)
// If any conversion error occurs, abort
if (errno != 0) {
sensordLogW() << "strtol(): Unable to convert string to long";
return;
}

switch(channel) {
case 0: {
Expand Down

0 comments on commit 7074a07

Please sign in to comment.