diff options
Diffstat (limited to 'drivers/acpi/acpica/utstring.c')
-rw-r--r-- | drivers/acpi/acpica/utstring.c | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c index cb1e9cc32d5f..45c0eb26b33d 100644 --- a/drivers/acpi/acpica/utstring.c +++ b/drivers/acpi/acpica/utstring.c | |||
@@ -310,7 +310,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | |||
310 | 310 | ||
311 | /* All done, normal exit */ | 311 | /* All done, normal exit */ |
312 | 312 | ||
313 | all_done: | 313 | all_done: |
314 | 314 | ||
315 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", | 315 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", |
316 | ACPI_FORMAT_UINT64(return_value))); | 316 | ACPI_FORMAT_UINT64(return_value))); |
@@ -318,7 +318,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | |||
318 | *ret_integer = return_value; | 318 | *ret_integer = return_value; |
319 | return_ACPI_STATUS(AE_OK); | 319 | return_ACPI_STATUS(AE_OK); |
320 | 320 | ||
321 | error_exit: | 321 | error_exit: |
322 | /* Base was set/validated above */ | 322 | /* Base was set/validated above */ |
323 | 323 | ||
324 | if (base == 10) { | 324 | if (base == 10) { |
@@ -584,3 +584,65 @@ void ut_convert_backslashes(char *pathname) | |||
584 | } | 584 | } |
585 | } | 585 | } |
586 | #endif | 586 | #endif |
587 | |||
588 | #if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) | ||
589 | /******************************************************************************* | ||
590 | * | ||
591 | * FUNCTION: acpi_ut_safe_strcpy, acpi_ut_safe_strcat, acpi_ut_safe_strncat | ||
592 | * | ||
593 | * PARAMETERS: Adds a "DestSize" parameter to each of the standard string | ||
594 | * functions. This is the size of the Destination buffer. | ||
595 | * | ||
596 | * RETURN: TRUE if the operation would overflow the destination buffer. | ||
597 | * | ||
598 | * DESCRIPTION: Safe versions of standard Clib string functions. Ensure that | ||
599 | * the result of the operation will not overflow the output string | ||
600 | * buffer. | ||
601 | * | ||
602 | * NOTE: These functions are typically only helpful for processing | ||
603 | * user input and command lines. For most ACPICA code, the | ||
604 | * required buffer length is precisely calculated before buffer | ||
605 | * allocation, so the use of these functions is unnecessary. | ||
606 | * | ||
607 | ******************************************************************************/ | ||
608 | |||
609 | u8 acpi_ut_safe_strcpy(char *dest, acpi_size dest_size, char *source) | ||
610 | { | ||
611 | |||
612 | if (ACPI_STRLEN(source) >= dest_size) { | ||
613 | return (TRUE); | ||
614 | } | ||
615 | |||
616 | ACPI_STRCPY(dest, source); | ||
617 | return (FALSE); | ||
618 | } | ||
619 | |||
620 | u8 acpi_ut_safe_strcat(char *dest, acpi_size dest_size, char *source) | ||
621 | { | ||
622 | |||
623 | if ((ACPI_STRLEN(dest) + ACPI_STRLEN(source)) >= dest_size) { | ||
624 | return (TRUE); | ||
625 | } | ||
626 | |||
627 | ACPI_STRCAT(dest, source); | ||
628 | return (FALSE); | ||
629 | } | ||
630 | |||
631 | u8 | ||
632 | acpi_ut_safe_strncat(char *dest, | ||
633 | acpi_size dest_size, | ||
634 | char *source, acpi_size max_transfer_length) | ||
635 | { | ||
636 | acpi_size actual_transfer_length; | ||
637 | |||
638 | actual_transfer_length = | ||
639 | ACPI_MIN(max_transfer_length, ACPI_STRLEN(source)); | ||
640 | |||
641 | if ((ACPI_STRLEN(dest) + actual_transfer_length) >= dest_size) { | ||
642 | return (TRUE); | ||
643 | } | ||
644 | |||
645 | ACPI_STRNCAT(dest, source, max_transfer_length); | ||
646 | return (FALSE); | ||
647 | } | ||
648 | #endif | ||