patch: Fix substring end parameter for accurate CPU ID

Signed-off-by: Vipul Gupta (@vipulgupta2048) <vipul@balena.io>
This commit is contained in:
Vipul Gupta (@vipulgupta2048) 2021-04-09 19:54:04 +05:30
parent 14efec2c7d
commit d058f43feb

View File

@ -69,7 +69,7 @@ export async function getCpuId(): Promise<string | undefined> {
try {
const buffer = await fs.readFile('/proc/device-tree/serial-number');
// Remove the null byte at the end
return buffer.toString('utf-8').substr(0, buffer.length - 2);
return buffer.toString('utf-8').replace(/\0/g, '');
} catch {
return undefined;
}