View | Details | Raw Unified | Return to bug 42557
Collapse All | Expand All

(-)a/lib/dns/message.c (-11 / +31 lines)
 Lines 1736-1742   dns_message_renderbegin(dns_message_t *m Link Here 
1736
	if (r.length < DNS_MESSAGE_HEADERLEN)
1736
	if (r.length < DNS_MESSAGE_HEADERLEN)
1737
		return (ISC_R_NOSPACE);
1737
		return (ISC_R_NOSPACE);
1738
1738
1739
	if (r.length < msg->reserved)
1739
	if (r.length - DNS_MESSAGE_HEADERLEN < msg->reserved)
1740
		return (ISC_R_NOSPACE);
1740
		return (ISC_R_NOSPACE);
1741
1741
1742
	/*
1742
	/*
 Lines 1863-1870   norender_rdataset(const dns_rdataset_t * Link Here 
1863
1863
1864
	return (ISC_TRUE);
1864
	return (ISC_TRUE);
1865
}
1865
}
1866
1867
#endif
1866
#endif
1867
1868
static isc_result_t
1869
renderset(dns_rdataset_t *rdataset, dns_name_t *owner_name,
1870
	  dns_compress_t *cctx, isc_buffer_t *target,
1871
	  unsigned int reserved, unsigned int options, unsigned int *countp)
1872
{
1873
	isc_result_t result;
1874
1875
	/*
1876
	 * Shrink the space in the buffer by the reserved amount.
1877
	 */
1878
	if (target->length - target->used < reserved)
1879
		return (ISC_R_NOSPACE);
1880
1881
	target->length -= reserved;
1882
	result = dns_rdataset_towire(rdataset, owner_name,
1883
				     cctx, target, options, countp);
1884
	target->length += reserved;
1885
1886
	return (result);
1887
}
1888
1868
isc_result_t
1889
isc_result_t
1869
dns_message_rendersection(dns_message_t *msg, dns_section_t sectionid,
1890
dns_message_rendersection(dns_message_t *msg, dns_section_t sectionid,
1870
			  unsigned int options)
1891
			  unsigned int options)
 Lines 1907-1912   dns_message_rendersection(dns_message_t Link Here 
1907
	/*
1928
	/*
1908
	 * Shrink the space in the buffer by the reserved amount.
1929
	 * Shrink the space in the buffer by the reserved amount.
1909
	 */
1930
	 */
1931
	if (msg->buffer->length - msg->buffer->used < msg->reserved)
1932
		return (ISC_R_NOSPACE);
1910
	msg->buffer->length -= msg->reserved;
1933
	msg->buffer->length -= msg->reserved;
1911
1934
1912
	total = 0;
1935
	total = 0;
 Lines 2183-2191   dns_message_renderend(dns_message_t *msg Link Here 
2183
		 * Render.
2206
		 * Render.
2184
		 */
2207
		 */
2185
		count = 0;
2208
		count = 0;
2186
		result = dns_rdataset_towire(msg->opt, dns_rootname,
2209
		result = renderset(msg->opt, dns_rootname, msg->cctx,
2187
					     msg->cctx, msg->buffer, 0,
2210
				   msg->buffer, msg->reserved, 0, &count);
2188
					     &count);
2189
		msg->counts[DNS_SECTION_ADDITIONAL] += count;
2211
		msg->counts[DNS_SECTION_ADDITIONAL] += count;
2190
		if (result != ISC_R_SUCCESS)
2212
		if (result != ISC_R_SUCCESS)
2191
			return (result);
2213
			return (result);
 Lines 2201-2209   dns_message_renderend(dns_message_t *msg Link Here 
2201
		if (result != ISC_R_SUCCESS)
2223
		if (result != ISC_R_SUCCESS)
2202
			return (result);
2224
			return (result);
2203
		count = 0;
2225
		count = 0;
2204
		result = dns_rdataset_towire(msg->tsig, msg->tsigname,
2226
		result = renderset(msg->tsig, msg->tsigname, msg->cctx,
2205
					     msg->cctx, msg->buffer, 0,
2227
				   msg->buffer, msg->reserved, 0, &count);
2206
					     &count);
2207
		msg->counts[DNS_SECTION_ADDITIONAL] += count;
2228
		msg->counts[DNS_SECTION_ADDITIONAL] += count;
2208
		if (result != ISC_R_SUCCESS)
2229
		if (result != ISC_R_SUCCESS)
2209
			return (result);
2230
			return (result);
 Lines 2224-2232   dns_message_renderend(dns_message_t *msg Link Here 
2224
		 * the owner name of a SIG(0) is irrelevant, and will not
2245
		 * the owner name of a SIG(0) is irrelevant, and will not
2225
		 * be set in a message being rendered.
2246
		 * be set in a message being rendered.
2226
		 */
2247
		 */
2227
		result = dns_rdataset_towire(msg->sig0, dns_rootname,
2248
		result = renderset(msg->sig0, dns_rootname, msg->cctx,
2228
					     msg->cctx, msg->buffer, 0,
2249
				   msg->buffer, msg->reserved, 0, &count);
2229
					     &count);
2230
		msg->counts[DNS_SECTION_ADDITIONAL] += count;
2250
		msg->counts[DNS_SECTION_ADDITIONAL] += count;
2231
		if (result != ISC_R_SUCCESS)
2251
		if (result != ISC_R_SUCCESS)
2232
			return (result);
2252
			return (result);

Return to bug 42557