1124f4c82Sjruoho /******************************************************************************
2124f4c82Sjruoho *
3124f4c82Sjruoho * Module Name: asluuid-- compiler UUID support
4124f4c82Sjruoho *
5124f4c82Sjruoho *****************************************************************************/
6124f4c82Sjruoho
7124f4c82Sjruoho /*
8*046a2985Schristos * Copyright (C) 2000 - 2023, Intel Corp.
9124f4c82Sjruoho * All rights reserved.
10124f4c82Sjruoho *
11124f4c82Sjruoho * Redistribution and use in source and binary forms, with or without
12124f4c82Sjruoho * modification, are permitted provided that the following conditions
13124f4c82Sjruoho * are met:
14124f4c82Sjruoho * 1. Redistributions of source code must retain the above copyright
15124f4c82Sjruoho * notice, this list of conditions, and the following disclaimer,
16124f4c82Sjruoho * without modification.
17124f4c82Sjruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18124f4c82Sjruoho * substantially similar to the "NO WARRANTY" disclaimer below
19124f4c82Sjruoho * ("Disclaimer") and any redistribution must be conditioned upon
20124f4c82Sjruoho * including a substantially similar Disclaimer requirement for further
21124f4c82Sjruoho * binary redistribution.
22124f4c82Sjruoho * 3. Neither the names of the above-listed copyright holders nor the names
23124f4c82Sjruoho * of any contributors may be used to endorse or promote products derived
24124f4c82Sjruoho * from this software without specific prior written permission.
25124f4c82Sjruoho *
26124f4c82Sjruoho * Alternatively, this software may be distributed under the terms of the
27124f4c82Sjruoho * GNU General Public License ("GPL") version 2 as published by the Free
28124f4c82Sjruoho * Software Foundation.
29124f4c82Sjruoho *
30124f4c82Sjruoho * NO WARRANTY
31124f4c82Sjruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32124f4c82Sjruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3346a330b4Schristos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34124f4c82Sjruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35124f4c82Sjruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36124f4c82Sjruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37124f4c82Sjruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38124f4c82Sjruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39124f4c82Sjruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40124f4c82Sjruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41124f4c82Sjruoho * POSSIBILITY OF SUCH DAMAGES.
42124f4c82Sjruoho */
43124f4c82Sjruoho
44124f4c82Sjruoho #include "aslcompiler.h"
45124f4c82Sjruoho
46124f4c82Sjruoho #define _COMPONENT ACPI_COMPILER
47124f4c82Sjruoho ACPI_MODULE_NAME ("asluuid")
48124f4c82Sjruoho
49124f4c82Sjruoho
50460301d4Schristos extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH];
51124f4c82Sjruoho
52124f4c82Sjruoho
53124f4c82Sjruoho /*******************************************************************************
54124f4c82Sjruoho *
55124f4c82Sjruoho * FUNCTION: AuValiduateUuid
56124f4c82Sjruoho *
57124f4c82Sjruoho * PARAMETERS: InString - 36-byte formatted UUID string
58124f4c82Sjruoho *
59124f4c82Sjruoho * RETURN: Status
60124f4c82Sjruoho *
61124f4c82Sjruoho * DESCRIPTION: Check all 36 characters for correct format
62124f4c82Sjruoho *
63124f4c82Sjruoho ******************************************************************************/
64124f4c82Sjruoho
65124f4c82Sjruoho ACPI_STATUS
AuValidateUuid(char * InString)66124f4c82Sjruoho AuValidateUuid (
67124f4c82Sjruoho char *InString)
68124f4c82Sjruoho {
69124f4c82Sjruoho UINT32 i;
70124f4c82Sjruoho
71124f4c82Sjruoho
72c72da027Schristos if (!InString || (strlen (InString) != UUID_STRING_LENGTH))
73124f4c82Sjruoho {
74124f4c82Sjruoho return (AE_BAD_PARAMETER);
75124f4c82Sjruoho }
76124f4c82Sjruoho
77124f4c82Sjruoho /* Check all 36 characters for correct format */
78124f4c82Sjruoho
79124f4c82Sjruoho for (i = 0; i < UUID_STRING_LENGTH; i++)
80124f4c82Sjruoho {
81124f4c82Sjruoho /* Must have 4 hyphens (dashes) in these positions: */
82124f4c82Sjruoho
83124f4c82Sjruoho if ((i == UUID_HYPHEN1_OFFSET) ||
84124f4c82Sjruoho (i == UUID_HYPHEN2_OFFSET) ||
85124f4c82Sjruoho (i == UUID_HYPHEN3_OFFSET) ||
86124f4c82Sjruoho (i == UUID_HYPHEN4_OFFSET))
87124f4c82Sjruoho {
88124f4c82Sjruoho if (InString[i] != '-')
89124f4c82Sjruoho {
90124f4c82Sjruoho return (AE_BAD_PARAMETER);
91124f4c82Sjruoho }
92124f4c82Sjruoho }
93124f4c82Sjruoho else
94124f4c82Sjruoho {
9571e38f1dSchristos /* All other positions must contain hex digits */
9671e38f1dSchristos
97124f4c82Sjruoho if (!isxdigit ((int) InString[i]))
98124f4c82Sjruoho {
99124f4c82Sjruoho return (AE_BAD_PARAMETER);
100124f4c82Sjruoho }
101124f4c82Sjruoho }
102124f4c82Sjruoho }
103124f4c82Sjruoho
104124f4c82Sjruoho return (AE_OK);
105124f4c82Sjruoho }
106