136 |
136 |
m->m_data += sizeof(struct udpiphdr);
|
137 |
137 |
|
138 |
138 |
tp->tp_op = htons(TFTP_OACK);
|
139 |
|
n += snprintf((char *)tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s",
|
|
139 |
n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s",
|
140 |
140 |
key) + 1;
|
141 |
|
n += snprintf((char *)tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u",
|
|
141 |
n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u",
|
142 |
142 |
value) + 1;
|
143 |
143 |
|
144 |
144 |
saddr.sin_addr = recv_tp->ip.ip_dst;
|
... | ... | |
283 |
283 |
|
284 |
284 |
/* skip header fields */
|
285 |
285 |
k = 0;
|
286 |
|
pktlen -= ((uint8_t *)&tp->x.tp_buf[0] - (uint8_t *)tp);
|
|
286 |
pktlen -= offsetof(struct tftp_t, x.tp_buf);
|
287 |
287 |
|
288 |
288 |
/* prepend tftp_prefix */
|
289 |
289 |
prefix_len = strlen(slirp->tftp_prefix);
|
... | ... | |
299 |
299 |
tftp_send_error(spt, 2, "Access violation", tp);
|
300 |
300 |
return;
|
301 |
301 |
}
|
302 |
|
req_fname[k] = (char)tp->x.tp_buf[k];
|
|
302 |
req_fname[k] = tp->x.tp_buf[k];
|
303 |
303 |
if (req_fname[k++] == '\0') {
|
304 |
304 |
break;
|
305 |
305 |
}
|
... | ... | |
311 |
311 |
return;
|
312 |
312 |
}
|
313 |
313 |
|
314 |
|
if (strcasecmp((const char *)&tp->x.tp_buf[k], "octet") != 0) {
|
|
314 |
if (strcasecmp(&tp->x.tp_buf[k], "octet") != 0) {
|
315 |
315 |
tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
|
316 |
316 |
return;
|
317 |
317 |
}
|
... | ... | |
340 |
340 |
while (k < pktlen) {
|
341 |
341 |
const char *key, *value;
|
342 |
342 |
|
343 |
|
key = (const char *)&tp->x.tp_buf[k];
|
|
343 |
key = &tp->x.tp_buf[k];
|
344 |
344 |
k += strlen(key) + 1;
|
345 |
345 |
|
346 |
346 |
if (k >= pktlen) {
|
... | ... | |
348 |
348 |
return;
|
349 |
349 |
}
|
350 |
350 |
|
351 |
|
value = (const char *)&tp->x.tp_buf[k];
|
|
351 |
value = &tp->x.tp_buf[k];
|
352 |
352 |
k += strlen(value) + 1;
|
353 |
353 |
|
354 |
354 |
if (strcasecmp(key, "tsize") == 0) {
|