Skip to content
Snippets Groups Projects
Commit c29737f9 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix warnings reported by nelgin.

The reason the comparison was changed to <= 0 is to do an explcit
check that eliminates negative numbers rather than the implicit ones
with the greater-than checks.
parent 7e505d6f
No related branches found
No related tags found
No related merge requests found
Pipeline #5995 canceled
......@@ -502,11 +502,11 @@ parse_file_handle(sbbs_t *sbbs, sftp_filehandle_t handle)
constexpr size_t nfdes = sizeof(sbbs->sftp_filedes) / sizeof(sbbs->sftp_filedes[0]);
long tmp = strtol(reinterpret_cast<char *>(handle->c_str), nullptr, 10);
if (tmp == 0)
if (tmp <= 0)
return UINT_MAX;
if (tmp > UINT_MAX)
return UINT_MAX;
if (tmp > nfdes)
if (static_cast<size_t>(tmp) > nfdes)
return UINT_MAX;
if (sbbs->sftp_filedes[tmp - 1] == nullptr)
return UINT_MAX;
......@@ -523,11 +523,11 @@ parse_dir_handle(sbbs_t *sbbs, sftp_dirhandle_t handle)
if (memcmp(handle->c_str, "D:", 2) != 0)
return UINT_MAX;
long tmp = strtol(reinterpret_cast<char *>(handle->c_str + 2), nullptr, 10);
if (tmp == 0)
if (tmp <= 0)
return UINT_MAX;
if (tmp > UINT_MAX)
return UINT_MAX;
if (tmp > nfdes)
if (static_cast<size_t>(tmp) > nfdes)
return UINT_MAX;
if (sbbs->sftp_dirdes[tmp - 1] == nullptr)
return UINT_MAX;
......
......@@ -30,11 +30,13 @@ appendfhandle(sftpc_state_t state, sftp_filehandle_t handle)
return appendstring(state, (sftp_str_t)handle);
}
#ifdef NOTYET
static bool
appenddhandle(sftpc_state_t state, sftp_dirhandle_t handle)
{
return appendstring(state, (sftp_str_t)handle);
}
#endif
static bool
cappendheader(sftpc_state_t state, uint8_t type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment