Skip to content

Commit

Permalink
Plug memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Jan 5, 2015
1 parent 137f602 commit f62e39e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions udp_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,16 @@ self_serve_cert_file(struct context *c, struct dns_header *header,
GETSHORT(qtype, p);
if (qtype == T_TXT && strcasecmp(c->provider_name, c->namebuff) == 0) {
// reply with signed certificate
size_t size = 1 + sizeof(struct SignedCert);
uint8_t *txt = malloc(size);
if (!txt)
return -1;
*txt = sizeof(struct SignedCert);
memcpy(txt + 1, &c->signed_cert, sizeof(struct SignedCert));
const size_t size = 1 + sizeof(struct SignedCert);
static uint8_t *txt;

if (!txt) {
txt = malloc(size);
if (!txt)
return -1;
*txt = sizeof(struct SignedCert);
memcpy(txt + 1, &c->signed_cert, sizeof(struct SignedCert));
}
if (add_resource_record
(header, nameoffset, &ansp, 0, NULL, T_TXT, C_IN, "t", size,
txt)) {
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#ifndef VERSION_H
#define VERSION_H

const char *the_version = "0.1.14.8.g915e06c";
const char *the_version = "0.1.14.19.g137f602";

#endif

0 comments on commit f62e39e

Please sign in to comment.