X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Facpi%2Fexecuter%2Fexstorob.c;h=4e2b442ee5a3912ded1cf18ddb76f16a1974890b;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=42c1feb2d05e6ff73b6f73e6211671399e3253b3;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c index 42c1feb2d..4e2b442ee 100644 --- a/drivers/acpi/executer/exstorob.c +++ b/drivers/acpi/executer/exstorob.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2004, R. Byron Moore + * Copyright (C) 2000 - 2005, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,6 +66,7 @@ acpi_status acpi_ex_store_buffer_to_buffer ( + acpi_object_type original_src_type, union acpi_operand_object *source_desc, union acpi_operand_object *target_desc) { @@ -93,34 +94,42 @@ acpi_ex_store_buffer_to_buffer ( return_ACPI_STATUS (AE_NO_MEMORY); } - target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; target_desc->buffer.length = length; } - /* - * Buffer is a static allocation, - * only place what will fit in the buffer. - */ + /* Copy source buffer to target buffer */ + if (length <= target_desc->buffer.length) { /* Clear existing buffer and copy in the new one */ ACPI_MEMSET (target_desc->buffer.pointer, 0, target_desc->buffer.length); ACPI_MEMCPY (target_desc->buffer.pointer, buffer, length); - } - else { + /* - * Truncate the source, copy only what will fit + * If the original source was a string, we must truncate the buffer, + * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer + * copy must not truncate the original buffer. */ + if (original_src_type == ACPI_TYPE_STRING) { + /* Set the new length of the target */ + + target_desc->buffer.length = length; + } + } + else { + /* Truncate the source, copy only what will fit */ + ACPI_MEMCPY (target_desc->buffer.pointer, buffer, target_desc->buffer.length); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Truncating src buffer from %X to %X\n", + "Truncating source buffer from %X to %X\n", length, target_desc->buffer.length)); } /* Copy flags */ target_desc->buffer.flags = source_desc->buffer.flags; + target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; return_ACPI_STATUS (AE_OK); }