jcs
/subtext
/amendments
/556
session: Use different values for each canary
jcs made amendment 556 about 1 year ago
--- session.c Fri Nov 17 12:27:44 2023
+++ session.c Fri Nov 17 14:04:55 2023
@@ -38,6 +38,11 @@
#include "console.h"
+#define OBUF_CANARY 0xaaaaaaaa
+#define IBUF_CANARY 0xe38e38e3
+#define OBUFLEN_CANARY 0x1c71c71c
+#define IBUFLEN_CANARY 0x55555555
+
struct session *sessions[MAX_SESSIONS] = { 0 };
short nsessions = 0;
@@ -104,10 +109,10 @@ session_create(char *node, char *via, struct node_func
sizeof(session->log.location));
session->last_input_at = session->established_at = Time;
- session->obuf_canary = 0xffffffff;
- session->ibuf_canary = 0xffffffff;
- session->obuflen_canary = 0xffffffff;
- session->ibuflen_canary = 0xffffffff;
+ session->obuf_canary = OBUF_CANARY;
+ session->ibuf_canary = IBUF_CANARY;
+ session->obuflen_canary = OBUFLEN_CANARY;
+ session->ibuflen_canary = IBUFLEN_CANARY;
for (n = 0; n < MAX_SESSIONS; n++) {
if (sessions[n] != NULL)
@@ -535,13 +540,13 @@ session_close(struct session *session)
void
session_check_buf_canaries(struct session *session)
{
- if (session->obuf_canary != 0xffffffff)
+ if (session->obuf_canary != OBUF_CANARY)
warn("obuf canary dead");
- if (session->ibuf_canary != 0xffffffff)
+ if (session->ibuf_canary != IBUF_CANARY)
warn("ibuf canary dead");
- if (session->obuflen_canary != 0xffffffff)
+ if (session->obuflen_canary != OBUFLEN_CANARY)
warn("obuflen canary dead");
- if (session->ibuflen_canary != 0xffffffff)
+ if (session->ibuflen_canary != IBUFLEN_CANARY)
warn("ibuflen canary dead");
}