Skip to content

Commit

Permalink
Drop a call to strlen()
Browse files Browse the repository at this point in the history
This is the same pattern used in the GUI daemon.
  • Loading branch information
DemiMarie committed Jan 31, 2023
1 parent 45b844a commit 9270d80
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions qrexec-lib/unpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,10 @@ static int validate_utf8_char(const unsigned char *untrusted_c) {

static size_t validate_path(const char *const untrusted_name, size_t allowed_leading_dotdot)
{
const size_t len = strlen(untrusted_name);
if (len == 0)
if (untrusted_name[0] == 0)
do_exit(ENOENT, untrusted_name);
size_t non_dotdot_components = 0;
for (size_t i = 0; i < len; ++i) {
for (size_t i = 0; untrusted_name[i]; ++i) {
if (i == 0 || untrusted_name[i - 1] == '/') {
switch (untrusted_name[i]) {
case '/':
Expand Down

0 comments on commit 9270d80

Please sign in to comment.