loader: tftp: Don't error on tftp error 0
tftp-hpa sends NAK with tftp error set to 0 when trying to get a directory and this is the first thing that loader tries to do and this make it hangs. Reviewed by: imp, tsoome MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D33406
This commit is contained in:
parent
b214fcceac
commit
bf07f2f862
@ -122,7 +122,7 @@ struct tftprecv_extra {
|
|||||||
|
|
||||||
#define TFTP_MAX_ERRCODE EOPTNEG
|
#define TFTP_MAX_ERRCODE EOPTNEG
|
||||||
static const int tftperrors[TFTP_MAX_ERRCODE + 1] = {
|
static const int tftperrors[TFTP_MAX_ERRCODE + 1] = {
|
||||||
0, /* ??? */
|
0, /* NAK */
|
||||||
ENOENT,
|
ENOENT,
|
||||||
EPERM,
|
EPERM,
|
||||||
ENOSPC,
|
ENOSPC,
|
||||||
@ -188,6 +188,7 @@ recvtftp(struct iodesc *d, void **pkt, void **payload, time_t tleft,
|
|||||||
struct tftphdr *t;
|
struct tftphdr *t;
|
||||||
void *ptr = NULL;
|
void *ptr = NULL;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
int tftp_error;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
extra = recv_extra;
|
extra = recv_extra;
|
||||||
@ -234,16 +235,20 @@ recvtftp(struct iodesc *d, void **pkt, void **payload, time_t tleft,
|
|||||||
return (got);
|
return (got);
|
||||||
}
|
}
|
||||||
case ERROR:
|
case ERROR:
|
||||||
if ((unsigned)ntohs(t->th_code) > TFTP_MAX_ERRCODE) {
|
tftp_error = ntohs(t->th_code);
|
||||||
printf("illegal tftp error %d\n", ntohs(t->th_code));
|
if ((unsigned)tftp_error > TFTP_MAX_ERRCODE) {
|
||||||
|
printf("illegal tftp error %d\n", tftp_error);
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
} else {
|
} else {
|
||||||
#ifdef TFTP_DEBUG
|
#ifdef TFTP_DEBUG
|
||||||
printf("tftp-error %d\n", ntohs(t->th_code));
|
printf("tftp-error %d\n", tftp_error);
|
||||||
#endif
|
#endif
|
||||||
errno = tftperrors[ntohs(t->th_code)];
|
errno = tftperrors[tftp_error];
|
||||||
}
|
}
|
||||||
free(ptr);
|
free(ptr);
|
||||||
|
/* If we got a NAK return 0, it's usually a directory */
|
||||||
|
if (tftp_error == 0)
|
||||||
|
return (0);
|
||||||
return (-1);
|
return (-1);
|
||||||
case OACK: {
|
case OACK: {
|
||||||
struct udphdr *uh;
|
struct udphdr *uh;
|
||||||
|
Loading…
Reference in New Issue
Block a user