diff --git a/src/interface/pxe/pxe_preboot.c b/src/interface/pxe/pxe_preboot.c index 09fa5fef..862c0dd7 100644 --- a/src/interface/pxe/pxe_preboot.c +++ b/src/interface/pxe/pxe_preboot.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "pxe.h" #include "pxe_callbacks.h" @@ -85,11 +86,13 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO * sources of options. */ if ( get_cached_info->BufferLimit == 0 ) { - DBG ( " without an external buffer. Aargh." ); - goto err; + get_cached_info->Buffer.segment = rm_ds; + get_cached_info->Buffer.offset = + ( unsigned int ) ( & __from_data16 ( dhcp_basemem ) ); + get_cached_info->BufferLimit = sizeof ( dhcp_basemem ); } - DBG ( " to %04x:%04x+%x\n", get_cached_info->Buffer.segment, + DBG ( " to %04x:%04x+%x", get_cached_info->Buffer.segment, get_cached_info->Buffer.offset, get_cached_info->BufferLimit ); /* Allocate space for temporary copy */ @@ -121,6 +124,7 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO /* Copy packet to client buffer */ buffer = real_to_user ( get_cached_info->Buffer.segment, get_cached_info->Buffer.offset ); + len = dhcppkt.len; copy_to_user ( buffer, 0, data, len ); get_cached_info->BufferSize = len; diff --git a/src/interface/pxe/pxe_tftp.c b/src/interface/pxe/pxe_tftp.c index 919d5c9e..56529b15 100644 --- a/src/interface/pxe/pxe_tftp.c +++ b/src/interface/pxe/pxe_tftp.c @@ -56,8 +56,10 @@ static unsigned int pxe_single_blkidx; * @v port Server port (in network byte order) * @v filename File name * @v blksize Requested block size, or 0 + * + * The URI string buffer must be at least @c PXE_URI_LEN bytes long. */ -static void pxe_tftp_build_uri ( char uri_string[PXE_URI_LEN], +static void pxe_tftp_build_uri ( char *uri_string, uint32_t ipaddress, unsigned int port, const unsigned char *filename, int blksize ) { @@ -73,7 +75,7 @@ static void pxe_tftp_build_uri ( char uri_string[PXE_URI_LEN], blksize = TFTP_MAX_BLKSIZE; tftp_set_request_blksize ( blksize ); - snprintf ( uri_string, sizeof ( uri_string ), "tftp://%s:%d%s%s", + snprintf ( uri_string, PXE_URI_LEN, "tftp://%s:%d%s%s", inet_ntoa ( address ), ntohs ( port ), ( ( filename[0] == '/' ) ? "" : "/" ), filename ); } @@ -372,6 +374,9 @@ PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE tftp_read_file->FileName, 0 ); DBG ( " %s", uri_string ); + DBG ( " to %08lx+%lx", tftp_read_file->Buffer, + tftp_read_file->BufferSize ); + /* Open URI */ fd = open ( uri_string ); if ( fd < 0 ) {