Some more security fixes.
This commit is contained in:
parent
a3774da4ee
commit
a6ee428f7b
2 changed files with 24 additions and 10 deletions
|
|
@ -1,3 +1,10 @@
|
|||
2026.07.16 – Security hardening.
|
||||
|
||||
- Fixed buffer overflow in ai_child_task: plen unsigned underflow when history entries exceed prefix buffer size, causing out-of-bounds writes via snprintf.
|
||||
- Fixed IRC injection in handle_nick_change: validate new nick for CRLF and control characters before storing in op cache.
|
||||
- Fixed control char leak in irc_msg: drop message on strdup failure instead of sending unsanitized input on the wire.
|
||||
- Fixed CRLF/control char injection in -pass argument: reject passwords containing control characters at startup.
|
||||
|
||||
2026.07.15 – Numerous optimizations and fixes.
|
||||
|
||||
- Fixed DB/TLS resource cleanup on partial startup failures and normal shutdown.
|
||||
|
|
|
|||
27
zynk.c
27
zynk.c
|
|
@ -29,7 +29,7 @@ int asprintf(char **, const char *, ...);
|
|||
|
||||
/* ---- constants ---- */
|
||||
|
||||
#define VERSION "0.32.1"
|
||||
#define VERSION "0.32.2"
|
||||
#define DEFAULT_SERVER "irc.libera.chat"
|
||||
#define OPENCODE_BIN "/usr/bin/opencode"
|
||||
#define CLR_RESET "\033[0m"
|
||||
|
|
@ -852,11 +852,18 @@ static void ai_child_task(Session *s, long long id, const char *agent) {
|
|||
"Just answer directly.");
|
||||
}
|
||||
if (have_history) {
|
||||
plen += snprintf(prefix + plen, sizeof prefix - plen,
|
||||
" My recent answers for context (only use if absolutely necessary): ");
|
||||
int space = (int)sizeof prefix - plen;
|
||||
if (space > 0)
|
||||
plen += snprintf(prefix + plen, space,
|
||||
" My recent answers for context (only use if absolutely necessary): ");
|
||||
if (plen >= (int)sizeof prefix) plen = (int)sizeof prefix - 1;
|
||||
for (int i = 0; i < MAX_HISTORY; i++) {
|
||||
if (history[i])
|
||||
plen += snprintf(prefix + plen, sizeof prefix - plen, "[%s] ", history[i]);
|
||||
space = (int)sizeof prefix - plen;
|
||||
if (space <= 0) break;
|
||||
if (history[i]) {
|
||||
plen += snprintf(prefix + plen, space, "[%s] ", history[i]);
|
||||
if (plen >= (int)sizeof prefix) plen = (int)sizeof prefix - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < MAX_HISTORY; i++) free(history[i]);
|
||||
|
|
@ -1029,10 +1036,9 @@ static void irc_msg(Session *s, const char *t, const char *txt) {
|
|||
}
|
||||
if (need_clean) {
|
||||
clean = strdup(send_txt);
|
||||
if (clean) {
|
||||
for (char *p = clean; *p; p++) if ((unsigned char)*p < 0x20 || (unsigned char)*p == 0x7f) *p = ' ';
|
||||
send_txt = clean;
|
||||
}
|
||||
if (!clean) return;
|
||||
for (char *p = clean; *p; p++) if ((unsigned char)*p < 0x20 || (unsigned char)*p == 0x7f) *p = ' ';
|
||||
send_txt = clean;
|
||||
}
|
||||
if (tb[0]) net_send(s, "PRIVMSG %s :%s\r\n", tb, send_txt);
|
||||
free(clean);
|
||||
|
|
@ -1421,6 +1427,7 @@ static void handle_nick_change(Session *s, const char *prefix, const char *param
|
|||
memcpy(src_nick, prefix, nlen); src_nick[nlen] = 0;
|
||||
const char *newnick = params;
|
||||
if (*newnick == ':') newnick++;
|
||||
if (!*newnick || has_crlf(newnick) || has_ctl(newnick)) return;
|
||||
chan_rename_op(src_nick, newnick);
|
||||
if (strcasecmp(src_nick, s->nick) == 0) {
|
||||
strncpy(s->nick, newnick, sizeof s->nick - 1);
|
||||
|
|
@ -1655,7 +1662,7 @@ int main(int argc, char **argv) {
|
|||
fprintf(stderr, CLR_RED "Invalid nick" CLR_RESET "\n");
|
||||
return 1;
|
||||
}
|
||||
if (has_crlf(passbuf) || has_crlf(joinbuf)) {
|
||||
if (has_crlf(passbuf) || has_crlf(joinbuf) || has_ctl(passbuf)) {
|
||||
fprintf(stderr, CLR_RED "Invalid IRC argument" CLR_RESET "\n");
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue