diff --git a/src/conf.c b/src/conf.c index e94d5dc..c679548 100644 --- a/src/conf.c +++ b/src/conf.c @@ -237,7 +237,11 @@ conf_parse_acl(json_t *j) { a->http_basic_auth = calloc(len, 1); base64_init_encodestate(&b64); - pos = base64_encode_block(plain, (int)plain_len, a->http_basic_auth, &b64); /* FIXME: check return value */ + pos = base64_encode_block(plain, (int)plain_len, a->http_basic_auth, &b64); + if(!pos) { /* nothing was encoded */ + fprintf(stderr, "Error: could not encode credentials as HTTP basic auth header\n"); + exit(1); + } base64_encode_blockend(a->http_basic_auth + pos, &b64); /* end string with \0 rather than \n */ diff --git a/src/formats/msgpack.c b/src/formats/msgpack.c index a3abc8b..372d5d5 100644 --- a/src/formats/msgpack.c +++ b/src/formats/msgpack.c @@ -61,7 +61,7 @@ msgpack_reply(redisAsyncContext *c, void *r, void *privdata) { } static int -on_msgpack_write(void *data, const char *s, unsigned int sz) { +on_msgpack_write(void *data, const char *s, size_t sz) { struct msg_out *out = data; diff --git a/src/slog.c b/src/slog.c index 0d7fd21..826a57e 100644 --- a/src/slog.c +++ b/src/slog.c @@ -51,6 +51,7 @@ slog(struct server *s, log_level level, const char *c = ".-*#"; time_t now; + struct tm now_tm, *lt_ret; char time_buf[64]; char msg[124]; char line[256]; /* bounds are checked. */ @@ -66,7 +67,13 @@ slog(struct server *s, log_level level, /* get current time */ now = time(NULL); - strftime(time_buf, sizeof(time_buf), "%d %b %H:%M:%S", localtime(&now)); + lt_ret = localtime_r(&now, &now_tm); + if(lt_ret) { + strftime(time_buf, sizeof(time_buf), "%d %b %H:%M:%S", lt_ret); + } else { + const char err_msg[] = "(NO TIME AVAILABLE)"; + strncpy(time_buf, err_msg, sizeof(err_msg)); + } /* generate output line. */ line_sz = snprintf(line, sizeof(line), diff --git a/src/websocket.c b/src/websocket.c index 4dae630..f790c13 100644 --- a/src/websocket.c +++ b/src/websocket.c @@ -349,7 +349,7 @@ ws_reply(struct cmd *cmd, const char *p, size_t sz) { frame[1] = sz; memcpy(frame + 2, p, sz); frame_sz = sz + 2; - } else if (sz > 125 && sz <= 65536) { + } else if (sz <= 65536) { uint16_t sz16 = htons(sz); frame[1] = 126; memcpy(frame + 2, &sz16, 2);