Skip to content

Commit

Permalink
Avoid use-after-free in builtin unicode
Browse files Browse the repository at this point in the history
Calculate length _before_ realloc, not after.
  • Loading branch information
ethomson committed Dec 21, 2023
1 parent 50aca17 commit bcd9642
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/unicode_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,13 @@ static inline bool unicode_builtin_encoding_convert(
goto done;
}

out_len = out_start - out;

if ((new_out = realloc(out, out_size)) == NULL) {
ntlm_client_set_errmsg(ntlm, "out of memory");
goto done;
}

out_len = out_start - out;

out = new_out;
out_start = new_out + out_len;
out_end = out + out_size;
Expand Down

0 comments on commit bcd9642

Please sign in to comment.