sendhex "00000014 65 00000001 0000 0776657273696F6E 0803312E30"
} -start
+server s5 {
+ recv 82
+ sendhex "00000000 65 00000001 0000"
+} -start
+
syslog S1 -level notice {
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+info: \"SPOA server is ok\".+check duration: [[:digit:]]+ms, status: 1/1 UP."
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv failed, reason: Layer7 invalid response.+info: \"unsupported version\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN."
} -start
+syslog S5 -level notice {
+ recv
+ expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be5/srv failed, reason: Layer7 invalid response.+info: \"invalid frame received\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN."
+} -start
+
haproxy h1 -conf {
global
.if feature(THREAD)
tcp-request content reject
server srv ${s1_addr}:${s1_port}
+ backend be5
+ log ${S5_addr}:${S5_port} daemon
+ option log-health-checks
+ option spop-check
+ server srv ${s5_addr}:${s5_port} check inter 1s rise 1 fall 1
+
} -start
syslog S1 -wait
syslog S2 -wait
syslog S3 -wait
syslog S4 -wait
+syslog S5 -wait
if (*(ptr+9) != 0 || *(ptr+10) != 0)
goto invalid_frame;
- if (b_data(&check->bi) < 4 + flen)
+ /* the length is read from the wire, make the comparison overflow-safe,
+ * and a frame with no payload is invalid: both the AGENT-HELLO and
+ * AGENT-DISCONNECT frames carry at least one K/V item.
+ */
+ if (flen > b_data(&check->bi) - 4)
goto too_short;
+ if (!flen)
+ goto invalid_frame;
ptr += 11;
end = b_tail(&check->bi);
while (ptr < end) {
char *str;
uint64_t sz;
- int ret;
+ int type, ret;
/* Decode the item key */
ret = spoe_decode_buffer(&ptr, end, &str, &sz);
/* Check "status-code" K/V item */
if (isteq(ist2(str, sz), ist("status-code"))) {
- int type = *ptr++;
+ if (ptr == end)
+ goto invalid_frame;
+ type = *ptr++;
/* The value must be an integer */
if ((type & SPOP_DATA_T_MASK) != SPOP_DATA_T_INT32 &&
/* Check "message" K/V item */
else if (isteq(ist2(str, sz), ist("message"))) {
- int type = *ptr++;
+ if (ptr == end)
+ goto invalid_frame;
+ type = *ptr++;
/* The value must be a string */
if ((type & SPOP_DATA_T_MASK) != SPOP_DATA_T_STR)
while (ptr < end) {
char *str;
uint64_t sz;
- int ret;
+ int type, ret;
/* Decode the item key */
ret = spoe_decode_buffer(&ptr, end, &str, &sz);
/* Check "version" K/V item */
if (isteq(ist2(str, sz), ist("version"))) {
- int type = *ptr++;
+ if (ptr == end)
+ goto invalid_frame;
+ type = *ptr++;
/* The value must be a string */
if ((type & SPOP_DATA_T_MASK) != SPOP_DATA_T_STR)
}
/* Check "max-frame-size" K/V item */
else if (isteq(ist2(str, sz), ist("max-frame-size"))) {
- int type = *ptr++;
+ if (ptr == end)
+ goto invalid_frame;
+ type = *ptr++;
/* The value must be integer */
if ((type & SPOP_DATA_T_MASK) != SPOP_DATA_T_INT32 &&
}
/* Check "capabilities" K/V item */
else if (isteq(ist2(str, sz), ist("capabilities"))) {
- int type = *ptr++;
+ if (ptr == end)
+ goto invalid_frame;
+ type = *ptr++;
/* The value must be a string */
if ((type & SPOP_DATA_T_MASK) != SPOP_DATA_T_STR)