|
Lines 52-58
sigjmp_buf toplevel;
Link Here
|
| 52 |
sigjmp_buf timeoutbuf; |
52 |
sigjmp_buf timeoutbuf; |
| 53 |
|
53 |
|
| 54 |
static void nak(int, const char *); |
54 |
static void nak(int, const char *); |
| 55 |
static int makerequest(int, const char *, struct tftphdr *, const char *); |
55 |
static int makerequest(int, const char *, void *, const char *); |
| 56 |
static void printstats(const char *, unsigned long); |
56 |
static void printstats(const char *, unsigned long); |
| 57 |
static void startclock(void); |
57 |
static void startclock(void); |
| 58 |
static void stopclock(void); |
58 |
static void stopclock(void); |
|
Lines 276-292
void tftp_recvfile(int fd, const char *name, const char *mode)
Link Here
|
| 276 |
|
276 |
|
| 277 |
static int |
277 |
static int |
| 278 |
makerequest(int request, const char *name, |
278 |
makerequest(int request, const char *name, |
| 279 |
struct tftphdr *tp, const char *mode) |
279 |
void *p, const char *mode) |
| 280 |
{ |
280 |
{ |
| 281 |
char *cp; |
281 |
char *cp; |
|
|
282 |
struct tftphdr *tp = p; |
| 283 |
size_t namelen, modelen; |
| 282 |
|
284 |
|
| 283 |
tp->th_opcode = htons((u_short) request); |
285 |
tp->th_opcode = htons((u_short) request); |
| 284 |
cp = (char *)&(tp->th_stuff); |
286 |
cp = (char*)p + offsetof(struct tftphdr, th_stuff); |
|
|
287 |
namelen = strlen(name); |
| 288 |
modelen = strlen(mode); |
| 289 |
if (namelen + modelen + 2 > SEGSIZE) |
| 290 |
perror("Filename is too long"); |
| 285 |
strcpy(cp, name); |
291 |
strcpy(cp, name); |
| 286 |
cp += strlen(name); |
292 |
cp += namelen; |
| 287 |
*cp++ = '\0'; |
293 |
*cp++ = '\0'; |
| 288 |
strcpy(cp, mode); |
294 |
strcpy(cp, mode); |
| 289 |
cp += strlen(mode); |
295 |
cp += modelen; |
| 290 |
*cp++ = '\0'; |
296 |
*cp++ = '\0'; |
| 291 |
return (cp - (char *)tp); |
297 |
return (cp - (char *)tp); |
| 292 |
} |
298 |
} |