mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-16 05:10:03 +01:00
Fix various coverity issues.
Mostly INTEGER_OVERFLOW (CWE-190).
This commit is contained in:
committed by
Milan Broz
parent
5fb3a0e854
commit
92a761e32c
@@ -158,7 +158,7 @@ static key_serial_t find_key_by_type_and_desc(const char *type, const char *desc
|
||||
char *newline;
|
||||
size_t buffer_len = 0;
|
||||
|
||||
int n;
|
||||
ssize_t n;
|
||||
|
||||
do {
|
||||
id = request_key(type, desc, NULL, 0);
|
||||
@@ -171,7 +171,8 @@ static key_serial_t find_key_by_type_and_desc(const char *type, const char *desc
|
||||
return 0;
|
||||
|
||||
while ((n = read(f, buf + buffer_len, sizeof(buf) - buffer_len - 1)) > 0) {
|
||||
buffer_len += n;
|
||||
/* coverity[overflow:FALSE] */
|
||||
buffer_len += (size_t)n;
|
||||
buf[buffer_len] = '\0';
|
||||
newline = strchr(buf, '\n');
|
||||
while (newline != NULL && buffer_len != 0) {
|
||||
|
||||
Reference in New Issue
Block a user