Revision 3b46e624 slirp/tftp.c
b/slirp/tftp.c | ||
---|---|---|
27 | 27 |
struct tftp_session { |
28 | 28 |
int in_use; |
29 | 29 |
unsigned char filename[TFTP_FILENAME_MAX]; |
30 |
|
|
30 |
|
|
31 | 31 |
struct in_addr client_ip; |
32 | 32 |
u_int16_t client_port; |
33 |
|
|
33 |
|
|
34 | 34 |
int timestamp; |
35 | 35 |
}; |
36 | 36 |
|
... | ... | |
146 | 146 |
m->m_data += if_maxlinkhdr; |
147 | 147 |
tp = (void *)m->m_data; |
148 | 148 |
m->m_data += sizeof(struct udpiphdr); |
149 |
|
|
149 |
|
|
150 | 150 |
tp->tp_op = htons(TFTP_OACK); |
151 | 151 |
n += sprintf(tp->x.tp_buf + n, "%s", key) + 1; |
152 | 152 |
n += sprintf(tp->x.tp_buf + n, "%u", value) + 1; |
153 | 153 |
|
154 | 154 |
saddr.sin_addr = recv_tp->ip.ip_dst; |
155 | 155 |
saddr.sin_port = recv_tp->udp.uh_dport; |
156 |
|
|
156 |
|
|
157 | 157 |
daddr.sin_addr = spt->client_ip; |
158 | 158 |
daddr.sin_port = spt->client_port; |
159 | 159 |
|
... | ... | |
186 | 186 |
m->m_data += if_maxlinkhdr; |
187 | 187 |
tp = (void *)m->m_data; |
188 | 188 |
m->m_data += sizeof(struct udpiphdr); |
189 |
|
|
189 |
|
|
190 | 190 |
tp->tp_op = htons(TFTP_ERROR); |
191 | 191 |
tp->x.tp_error.tp_error_code = htons(errorcode); |
192 | 192 |
strcpy(tp->x.tp_error.tp_msg, msg); |
... | ... | |
233 | 233 |
m->m_data += if_maxlinkhdr; |
234 | 234 |
tp = (void *)m->m_data; |
235 | 235 |
m->m_data += sizeof(struct udpiphdr); |
236 |
|
|
236 |
|
|
237 | 237 |
tp->tp_op = htons(TFTP_DATA); |
238 | 238 |
tp->x.tp_data.tp_block_nr = htons(block_nr); |
239 | 239 |
|
... | ... | |
297 | 297 |
else { |
298 | 298 |
return; |
299 | 299 |
} |
300 |
|
|
300 |
|
|
301 | 301 |
if (src[k] == '\0') { |
302 | 302 |
break; |
303 | 303 |
} |
304 | 304 |
} |
305 |
|
|
305 |
|
|
306 | 306 |
if (k >= n) { |
307 | 307 |
return; |
308 | 308 |
} |
309 |
|
|
309 |
|
|
310 | 310 |
k++; |
311 |
|
|
311 |
|
|
312 | 312 |
/* check mode */ |
313 | 313 |
if ((n - k) < 6) { |
314 | 314 |
return; |
315 | 315 |
} |
316 |
|
|
316 |
|
|
317 | 317 |
if (memcmp(&src[k], "octet\0", 6) != 0) { |
318 | 318 |
tftp_send_error(spt, 4, "Unsupported transfer mode", tp); |
319 | 319 |
return; |
... | ... | |
338 | 338 |
} |
339 | 339 |
|
340 | 340 |
/* check if the file exists */ |
341 |
|
|
341 |
|
|
342 | 342 |
if (tftp_read_data(spt, 0, spt->filename, 0) < 0) { |
343 | 343 |
tftp_send_error(spt, 1, "File not found", tp); |
344 | 344 |
return; |
Also available in: Unified diff