From: Michael Brown Date: Fri, 7 Dec 2007 01:06:37 +0000 (+0000) Subject: Don't complain when callers provide too-short buffers for X-Git-Tag: v0.9.3~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b0e147e0de3c3f2747d200a20e9a1327fac0cf4;p=thirdparty%2Fipxe.git Don't complain when callers provide too-short buffers for PXENV_GET_CACHED_INFO. NTLDR does this. --- diff --git a/src/interface/pxe/pxe_preboot.c b/src/interface/pxe/pxe_preboot.c index 5e6a67032..634514978 100644 --- a/src/interface/pxe/pxe_preboot.c +++ b/src/interface/pxe/pxe_preboot.c @@ -168,15 +168,14 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO get_cached_info->BufferLimit ); } else { /* Copy packet to client buffer */ - if ( len < sizeof ( cached_info[idx] ) ) { - DBG ( " buffer too short" ); - goto err; - } + if ( len > sizeof ( cached_info[idx] ) ) + len = sizeof ( cached_info[idx] ); + if ( len < sizeof ( cached_info[idx] ) ) + DBG ( " buffer may be too short" ); buffer = real_to_user ( get_cached_info->Buffer.segment, get_cached_info->Buffer.offset ); - copy_to_user ( buffer, 0, &cached_info[idx], - sizeof ( cached_info[idx] ) ); - get_cached_info->BufferSize = sizeof ( cached_info[idx] ); + copy_to_user ( buffer, 0, &cached_info[idx], len ); + get_cached_info->BufferSize = len; } get_cached_info->Status = PXENV_STATUS_SUCCESS;