Skip to content

Commit

Permalink
Fix undefined behaviour in the event of a zero length session id
Browse files Browse the repository at this point in the history
Don't attempt to memcpy a NULL pointer if the length is 0.
  • Loading branch information
mattcaswell committed May 1, 2024
1 parent d857a4a commit 1f42c09
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ssl/ssl_sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,9 @@ int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid,
return 0;
}
s->session_id_length = sid_len;
if (sid != s->session_id)
if (sid != s->session_id && sid_len > 0)
memcpy(s->session_id, sid, sid_len);

return 1;
}

Expand Down

0 comments on commit 1f42c09

Please sign in to comment.