Skip to content

Commit

Permalink
fix warnings and potential edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
g3gg0 committed Jul 26, 2023
1 parent bec6210 commit 29e2a82
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cyclone/cyclone_tcp/http/http_server_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ void httpParseContentTypeField(HttpConnection *connection,
if (n < HTTP_SERVER_BOUNDARY_MAX_LEN)
{
// Copy the boundary string
osStrncpy(connection->request.boundary, token, n);
osStrcpy(connection->request.boundary, token);
// Properly terminate the string
connection->request.boundary[n] = '\0';

Expand Down
2 changes: 1 addition & 1 deletion src/handler_rtnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static void escapeString(const char_t *input, size_t size, char_t *output)
if (input[i] == replacements[k][0])
{
size_t len = osStrlen(replacements[k]);
osStrncpy(&output[j], replacements[k], len);
osStrcpy(&output[j], replacements[k]);
j += len;
replaced = true;
break;
Expand Down
12 changes: 9 additions & 3 deletions src/tls_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ error_t der_get_length(FsFile *fp, size_t *outLength)
uint32_t length = 0;
for (uint8_t i = 0; i < num_bytes; i++)
{
fread(&len, 1, 1, fp);
length = (length << 8) | len;
error_t err = fsReadFile(fp, &derLen, 1, &len);
if (err != NO_ERROR || len != 1)
{
*outLength = 0;
return err;
}

length = (length << 8) | derLen;
}
*outLength = length;
}
Expand Down Expand Up @@ -253,7 +259,7 @@ error_t read_certificate(const char_t *filename, char_t **buffer, size_t *length

// Close file
if (fp != NULL)
fclose(fp);
fsCloseFile(fp);

// Any error to report?
if (error)
Expand Down

0 comments on commit 29e2a82

Please sign in to comment.