-/* $OpenBSD: check_tcp.c,v 1.57 2019/09/15 19:23:29 rob Exp $ */
+/* $OpenBSD: check_tcp.c,v 1.58 2021/09/18 19:44:46 claudio Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
/*
* ensure string is nul-terminated.
*/
- b = ibuf_reserve(cte->buf, 1);
+ b = strndup(cte->buf->buf, ibuf_size(cte->buf));
if (b == NULL)
fatal("out of memory");
- *b = '\0';
- if (fnmatch(cte->table->conf.exbuf, cte->buf->buf, 0) == 0) {
+ if (fnmatch(cte->table->conf.exbuf, b, 0) == 0) {
cte->host->he = HCE_SEND_EXPECT_OK;
cte->host->up = HOST_UP;
+ free(b);
return (0);
}
+ free(b);
}
+
cte->host->he = HCE_SEND_EXPECT_FAIL;
cte->host->up = HOST_UNKNOWN;
-
- /*
- * go back to original position.
- */
- cte->buf->wpos--;
return (1);
}