blob: e657bdd922b3dbc6a91d826e073760f6f4f9ca2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/* SPDX-License-Identifier: GPL-2.0-only */
#include <cbfs.h>
#include <device/device.h>
#include <smbios.h>
#include <string.h>
#include <uuid.h>
void smbios_system_set_uuid(u8 *uuid)
{
/* Add 3 more bytes: 2 for possible CRLF and third for NULL char */
char uuid_str[UUID_STRLEN + 3] = {0};
uint8_t system_uuid[UUID_LEN];
size_t uuid_len = cbfs_load("system_uuid", uuid_str, UUID_STRLEN);
if (uuid_len >= UUID_STRLEN && uuid_len <= UUID_STRLEN + 3) {
/* Cut off any trailing whitespace like CR or LF */
uuid_str[UUID_STRLEN] = '\0';
if (!parse_uuid(system_uuid, uuid_str))
memcpy(uuid, system_uuid, UUID_LEN);
}
}
|