reworked some of the string handling to check for strchr and
strrchr return values. Removed check for unsigned to be negative,
that's not going to happen!
References:
Coverity 288525
return -1;
}
fclose(file);
- startcomm = strchr(buf, '(') + 1;
- endcomm = strrchr(startcomm, ')');
+ if ( NULL == ( startcomm = strchr(buf, '(')))
+ return -1;
+ startcomm++;
+ if ( NULL == ( endcomm = strrchr(startcomm, ')')))
+ return -1;
lencomm = endcomm - startcomm;
- if (lencomm < 0)
- lencomm = 0;
if (lencomm > COMM_LEN -1)
lencomm = COMM_LEN -1;
strncpy(comm, startcomm, lencomm);