Get address sanitizer mostly working

This commit is contained in:
Justine Tunney 2020-09-03 05:44:37 -07:00
parent 1f1f3cd477
commit 7327c345f9
149 changed files with 3777 additions and 3457 deletions

View file

@ -45,10 +45,11 @@
*/
int parsehoststxt(struct HostsTxt *ht, FILE *f) {
int rc = 0;
char stackline[128];
char *line = stackline;
size_t linecap = sizeof(stackline);
while ((getline(&line, &linecap, f)) != -1) {
char *line;
size_t linesize;
line = NULL;
linesize = 0;
while ((getline(&line, &linesize, f)) != -1) {
struct HostsTxtEntry entry;
char *addr, *name, *tok, *comment;
if ((comment = strchr(line, '#'))) *comment = '\0';
@ -64,6 +65,6 @@ int parsehoststxt(struct HostsTxt *ht, FILE *f) {
}
}
}
free_s(&line);
free(line);
return rc | ferror(f);
}

View file

@ -20,6 +20,7 @@
#include "libc/alg/arraylist.h"
#include "libc/dns/dns.h"
#include "libc/dns/resolvconf.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/sock.h"
#include "libc/stdio/stdio.h"
@ -44,13 +45,14 @@
int parseresolvconf(struct ResolvConf *resolv, struct FILE *f) {
/* TODO(jart): options ndots:5 */
int rc = 0;
char stackline[32];
char *line = stackline;
size_t linecap = sizeof(stackline);
char *line;
size_t linesize;
struct sockaddr_in nameserver;
line = NULL;
linesize = 0;
nameserver.sin_family = AF_INET;
nameserver.sin_port = htons(DNS_PORT);
while (getline(&line, &linecap, f) != -1) {
while (getline(&line, &linesize, f) != -1) {
char *directive, *value, *tok, *comment;
if ((comment = strchr(line, '#'))) *comment = '\0';
if ((directive = strtok_r(line, " \t\r\n\v", &tok)) &&
@ -61,6 +63,6 @@ int parseresolvconf(struct ResolvConf *resolv, struct FILE *f) {
}
}
}
free_s(&line);
free(line);
return rc | ferror(f);
}