void read_req(void) {
char buf[128];
int i;
gets(buf);
i = atoi(buf);
}
0x00
^ ....
| +------------------+ <- esp
| return addr. |
+------------------+
| &buf |
+------------------+
| i |
+------------------+ +----------+<--+
| buf[0:3] | | shell | |
| ... | | code | |
+------------------+ <- ebp | | |
| saved ebp | | | |
+------------------+ | | |
| return addr | |//////////|---+
+------------------+ +----------+
0x00
+------------------+
| return addr. |
+------------------+
| saved ebp |
+------------------+ +----------+
| buf[0:3] | | shell |
| ... | | code |
+------------------+ | |
| i | | |
| +------------------+ +----------+
v ...
0x00
+------------------+
| return addr. |
+------------------+
| saved ebp |
+------------------+ <---+ +----------+<--+
| buf[0:3] | | | shell | |
| ... | | | code | |
+------------------+ | | | |
| i | | | | |
+------------------+ | | | |
| &buf | ----+ | | |
+------------------+ | | |
| return addr. | |//////////|---+
+------------------+ +----------+
| saved ebp |
| +------------------+
v ...
struct Msg {
u8 type; /* 1 bytes */
u16 length; /* 2 bytes */
char* payload; /* len(payload) = length */
char* padding[]; /* minimum: 16 */
};
// Msg = [type][len][payload][padding]
type = *p++; // p = Msg
n2s(p, length); // length = p.length
payload = p; // payload = p.payload
if (type == TLS1_HB_REQUEST) {
unsigned char *buf, *bp;
buf = OPENSSL_malloc(1 + 2 + length + padding);
bp = buf;
// bp = Msg (type/length)
*bp++ = TLS1_HB_RESPONSE;
s2n(length, bp);
// copy payload to the buffer
memcpy(bp, payload, length);
ssl3_write_bytes(s, TLS1_RT_HEARTBEAT,
buf, 1 + 2 + length + padding);
/* discard zero-size heartbeat */
if (1 + 2 + 16 > s->s3->rrec.length)
return 0;
type = *p++;
n2s(p, payload);
/* discard if it lies */
if (1 + 2 + payload + 16 > s->s3->rrec.length)
return 0;
count > [(ULONG_MAX - sizeof(struct rps_dev_flow_table)) \
/ sizeof(struct rps_dev_flow)]
AND
count <= 1 << 30
nan size_t page_count
nan size_t page_total = pg_start + page_count
if (isnan(pg_total) || (pg_total > num_entries))
return EINVAL;