Browse Source

Declare more missing functions and deal with lack of SO_NOSIGPIPE

master
Causal Agent 1 week ago
parent
commit
c7223d7e0c
Signed by: C. McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
4 changed files with 14 additions and 4 deletions
  1. 2
    0
      Makefile
  2. 1
    0
      bounce.c
  3. 7
    4
      compat.h
  4. 4
    0
      dispatch.c

+ 2
- 0
Makefile View File

@@ -33,6 +33,8 @@ pounce: ${OBJS}

${OBJS}: bounce.h compat.h

dispatch.o: compat.h

tags: *.c *.h
ctags -w *.c *.h


+ 1
- 0
bounce.c View File

@@ -372,6 +372,7 @@ int main(int argc, char *argv[]) {

signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);
signal(SIGPIPE, SIG_IGN);
signal(SIGINFO, signalHandler);
signal(SIGUSR1, signalHandler);


+ 7
- 4
compat.h View File

@@ -17,14 +17,17 @@
#include <stdint.h>
#include <stdlib.h>

#ifdef NO_EXPLICIT_BZERO
// libcrypto defines these functions if libc doesn't.
void explicit_bzero(void *b, size_t len);
#endif

#ifdef NO_ARC4RANDOM
size_t strlcpy(char *restrict dst, const char *restrict src, size_t dstsize);
size_t strlcat(char *restrict dst, const char *restrict src, size_t dstsize);
uint32_t arc4random(void);
void arc4random_buf(void *buf, size_t nbytes);
uint32_t arc4random_uniform(uint32_t upper_bound);

// The default value of SO_RCVLOWAT is 1 anyway...
#ifndef SO_NOSIGPIPE
#define SO_NOSIGPIPE SO_RCVLOWAT
#endif

#ifndef SIGINFO

+ 4
- 0
dispatch.c View File

@@ -19,6 +19,7 @@
#include <netdb.h>
#include <netinet/in.h>
#include <poll.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -32,6 +33,8 @@
#include <sys/capsicum.h>
#endif

#include "compat.h"

static struct {
struct pollfd *ptr;
size_t len, cap;
@@ -231,6 +234,7 @@ int main(int argc, char *argv[]) {
if (error) err(EX_IOERR, "listen");
}

signal(SIGPIPE, SIG_IGN);
for (;;) {
int nfds = poll(
event.ptr, event.len, (event.len > binds ? timeout : -1)

Loading…
Cancel
Save