Commit bfb2a81b authored by Mark Andrews's avatar Mark Andrews
Browse files

Fix initial towire/fromwire so they work.

parent 3f284311
......@@ -298,6 +298,7 @@ main(int argc, char **argv) {
struct tm *tm;
time_t now;
char year[11];
int lasttype;
argc = argc;
argv = argv;
......@@ -355,11 +356,13 @@ main(int argc, char **argv) {
fprintf(stdout, "\n#define TYPENAMES%s\n",
types != NULL ? " \\" : "");
lasttype = 0;
for (tt = types; tt != NULL ; tt = tt->next)
if (tt->class == 0)
if (tt->type != lasttype)
fprintf(stdout,
"\t{ %d, \"%s\" },%s\n",
tt->type, tt->typename,
lasttype = tt->type, tt->typename,
tt->next != NULL ? " \\" : "");
fputs("\n", stdout);
......
......@@ -331,7 +331,7 @@ txt_fromwire(isc_buffer_t *source, isc_buffer_t *target) {
return (DNS_R_UNKNOWN);
isc_buffer_available(target, &tregion);
if (n < tregion.length)
if (n > tregion.length)
return (DNS_R_NOSPACE);
memcpy(tregion.base, sregion.base, n);
......
......@@ -84,13 +84,16 @@ fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
static dns_result_t
towire_hinfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t region;
cctx = cctx;
if (target->length < rdata->length)
isc_buffer_available(target, &region);
if (region.length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(target->base, rdata->data, rdata->length);
memcpy(region.base, rdata->data, rdata->length);
isc_buffer_add(target, rdata->length);
return (DNS_R_SUCCESS);
}
......
......@@ -84,13 +84,16 @@ fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
static dns_result_t
towire_hinfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t region;
cctx = cctx;
if (target->length < rdata->length)
isc_buffer_available(target, &region);
if (region.length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(target->base, rdata->data, rdata->length);
memcpy(region.base, rdata->data, rdata->length);
isc_buffer_add(target, rdata->length);
return (DNS_R_SUCCESS);
}
......
......@@ -190,7 +190,7 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_remaining(target, &tregion);
isc_buffer_available(target, &tregion);
if (tregion.length < 20)
return (DNS_R_NOSPACE);
......
......@@ -190,7 +190,7 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_remaining(target, &tregion);
isc_buffer_available(target, &tregion);
if (tregion.length < 20)
return (DNS_R_NOSPACE);
......
......@@ -86,14 +86,16 @@ fromwire_txt(dns_rdataclass_t class, dns_rdatatype_t type,
static dns_result_t
towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t region;
cctx = cctx;
if (target->length < rdata->length)
isc_buffer_available(target, &region);
if (region.length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(target->base, rdata->data, rdata->length);
/*XXX*/
memcpy(region.base, rdata->data, rdata->length);
isc_buffer_add(target, rdata->length);
return (DNS_R_SUCCESS);
}
......
......@@ -86,14 +86,16 @@ fromwire_txt(dns_rdataclass_t class, dns_rdatatype_t type,
static dns_result_t
towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t region;
cctx = cctx;
if (target->length < rdata->length)
isc_buffer_available(target, &region);
if (region.length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(target->base, rdata->data, rdata->length);
/*XXX*/
memcpy(region.base, rdata->data, rdata->length);
isc_buffer_add(target, rdata->length);
return (DNS_R_SUCCESS);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment