Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 7 additions & 5 deletions ldns/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,13 @@ ldns_buffer_available(const ldns_buffer *buffer, size_t count)
* \param[in] data pointer to the data to write to the buffer
* \param[in] count the number of bytes of data to write
*/
INLINE void
INLINE size_t
ldns_buffer_write_at(ldns_buffer *buffer, size_t at, const void *data, size_t count)
{
assert(ldns_buffer_available_at(buffer, at, count));
memcpy(buffer->_data + at, data, count);
size_t avail = ldns_buffer_remaining_at(buffer, at);
size_t copy = count < avail ? count : avail;
memcpy(buffer->_data + at, data, copy);
return copy;
}

/**
Expand All @@ -372,8 +374,8 @@ ldns_buffer_write_at(ldns_buffer *buffer, size_t at, const void *data, size_t co
INLINE void
ldns_buffer_write(ldns_buffer *buffer, const void *data, size_t count)
{
ldns_buffer_write_at(buffer, buffer->_position, data, count);
buffer->_position += count;
size_t copied = ldns_buffer_write_at(buffer, buffer->_position, data, count);
buffer->_position += copied;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions str2host.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ ldns_str2rdf_dname(ldns_rdf **d, const char *str)
/* root label */
if (1 == len && *str == '.') {
*d = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_DNAME, 1, "\0");
return LDNS_STATUS_OK;
return *d?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
}

/* get on with the rest */
Expand Down Expand Up @@ -457,7 +457,7 @@ ldns_str2rdf_dname(ldns_rdf **d, const char *str)
len++;

*d = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_DNAME, len, buf);
return LDNS_STATUS_OK;
return *d?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
}

ldns_status
Expand Down