X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=blobdiff_plain;f=util.c;h=94f9e35679acf34c7d500fade5e25919087cd9cc;hp=fc6f6264cf433ba84211858df529b986b377b714;hb=f1af5809ba842b5ca0799a8e085e92967976ac34;hpb=4fb0f88d53fc60395a4a87b7a9ca1245ba033ee7 diff --git a/util.c b/util.c index fc6f626..94f9e35 100644 --- a/util.c +++ b/util.c @@ -169,6 +169,13 @@ void setcloexec(int fd) { if (r<0) fatal_perror("fcntl(,F_SETFD,|FD_CLOEXEC) failed"); } +void pipe_cloexec(int fd[2]) { + int r=pipe(fd); + if (r) fatal_perror("pipe"); + setcloexec(fd[0]); + setcloexec(fd[1]); +} + static const char *phases[NR_PHASES]={ "PHASE_INIT", "PHASE_GETOPTS", @@ -296,7 +303,7 @@ void buf_append_string(struct buffer_if *buf, cstring_t s) len=strlen(s); /* fixme: if string is longer than 65535, result is a corrupted packet */ buf_append_uint16(buf,len); - memcpy(buf_append(buf,len),s,len); + BUF_ADD_BYTES(append,buf,s,len); } void buffer_new(struct buffer_if *buf, int32_t len)