Minor adjustments and fixed some warnings

This commit is contained in:
frekky 2015-10-27 17:27:11 +08:00
parent 87edca99b4
commit 91c095e063
4 changed files with 11 additions and 6 deletions

View File

@ -282,7 +282,9 @@ do_detach()
{ {
#ifndef WINDOWS32 #ifndef WINDOWS32
fprintf(stderr, "Detaching from terminal...\n"); fprintf(stderr, "Detaching from terminal...\n");
daemon(0, 0); if (daemon(0, 0) != 0) {
err(1, "Failed to detach from terminal. Try running in foreground.");
}
umask(0); umask(0);
alarm(0); alarm(0);
#else #else
@ -310,7 +312,8 @@ read_password(char *buf, size_t len)
fprintf(stderr, "Enter password: "); fprintf(stderr, "Enter password: ");
fflush(stderr); fflush(stderr);
#ifndef WINDOWS32 #ifndef WINDOWS32
fscanf(stdin, "%79[^\n]", pwd); if (!fscanf(stdin, "%79[^\n]", pwd))
err(1, "EOF while reading password!");
#else #else
for (i = 0; i < sizeof(pwd); i++) { for (i = 0; i < sizeof(pwd); i++) {
pwd[i] = getch(); pwd[i] = getch();

View File

@ -79,7 +79,7 @@ extern const unsigned char raw_header[RAW_HDR_LEN];
#define DOWNSTREAM_HDR 3 #define DOWNSTREAM_HDR 3
#define DOWNSTREAM_PING_HDR 7 #define DOWNSTREAM_PING_HDR 7
#define UPSTREAM_HDR 6 #define UPSTREAM_HDR 6
#define UPSTREAM_PING 6 #define UPSTREAM_PING 11
/* handy debug printing macro */ /* handy debug printing macro */
#define DEBUG(level, ...) \ #define DEBUG(level, ...) \

View File

@ -408,7 +408,7 @@ dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, siz
unsigned short type; unsigned short type;
char *data; char *data;
unsigned short rlen; unsigned short rlen;
int id; uint16_t id;
int rv; int rv;
rv = 0; rv = 0;
@ -428,7 +428,6 @@ dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, siz
ancount = ntohs(header->ancount); ancount = ntohs(header->ancount);
id = ntohs(header->id); id = ntohs(header->id);
id = id & 0xFFFF; /* Kill any sign extension */
rlen = 0; rlen = 0;

View File

@ -43,7 +43,10 @@ get_resolvconf_addr()
err(1, "/etc/resolv.conf"); err(1, "/etc/resolv.conf");
while (feof(fp) == 0) { while (feof(fp) == 0) {
fgets(buf, sizeof(buf), fp); if (!fgets(buf, sizeof(buf), fp)) {
/* resolv.conf is empty (we got to EOF without reading anything yet */
err(1, "/etc/resolv.conf is empty! Please specify a nameserver.");
}
if (sscanf(buf, "nameserver %15s", addr) == 1) { if (sscanf(buf, "nameserver %15s", addr) == 1) {
rv = addr; rv = addr;