Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix input termination for pgpParsePkts #325

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions librepo/gpg_rpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ lr_gpg_import_key_from_memory(const char *key, size_t key_len, const char *home_

// `pgpParsePkts` needs null-terminated input, if null byte not found, make a local null-terminated copy
g_autofree gchar * key_with_null_byte = NULL;
if (memchr(block_begin, '\0', key_len) == NULL) {
if (memchr(block_begin, '\0', key_len - (block_begin - key)) == NULL) {
key_with_null_byte = g_new(gchar, key_len + 1);
memcpy(key_with_null_byte, key, key_len);
key_with_null_byte[key_len] = '\0';
Expand Down Expand Up @@ -533,7 +533,7 @@ check_signature(const gchar * sig_buf, ssize_t sig_buf_len, const gchar * data,

// `pgpParsePkts` needs null-terminated input, if null byte not found, make a local null-terminated copy
g_autofree gchar * sig_buf_with_null_byte = NULL;
if (memchr(block_begin, '\0', sig_buf_len) == NULL) {
if (memchr(block_begin, '\0', sig_buf_len - (block_begin - sig_buf)) == NULL) {
sig_buf_with_null_byte = g_new(gchar, sig_buf_len + 1);
memcpy(sig_buf_with_null_byte, sig_buf, sig_buf_len);
sig_buf_with_null_byte[sig_buf_len] = '\0';
Expand Down
Loading