return SSM_PASS;
}
+#define HELOMAX 1024
static int
ssm_nmsg_helo(struct conn *c, const char *cmd, int len, int argoff)
{
struct ssm_nmsg_state *nms = ssm_getpriv(&ss_module, c);
- uint8_t *data = malloc(len + 1);
+ char buf[HELOMAX];
+ const char *s;
+ char *t, *end;
+
+ if (len - argoff > HELOMAX - 1) return SSM_PASS;
+
+ for (s = cmd + argoff, end = t = buf; s < cmd + len; s++) {
+ *t++ = *s;
+ if (*s != '\r' && *s != '\n') end = t;
+ }
+ *end = 0;
- memcpy(data,cmd,len);
- data[len] = 0;
if (nms && nms->msg)
- nmsg_message_set_field(nms->msg, "helo", 0, data+argoff,
- len - argoff + 1);
- free(data);
+ nmsg_message_set_field(nms->msg, "helo", 0, (uint8_t *)buf,
+ end - buf + 1);
return SSM_PASS;
}