mirror of
https://github.com/token2/fido2-manage.git
synced 2026-04-09 18:55:38 +00:00
Add files via upload
This commit is contained in:
31
src/util.c
Normal file
31
src/util.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Yubico AB. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style
|
||||
* license that can be found in the LICENSE file.
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "fido.h"
|
||||
|
||||
int
|
||||
fido_to_uint64(const char *str, int base, uint64_t *out)
|
||||
{
|
||||
char *ep;
|
||||
unsigned long long ull;
|
||||
|
||||
errno = 0;
|
||||
ull = strtoull(str, &ep, base);
|
||||
if (str == ep || *ep != '\0')
|
||||
return -1;
|
||||
else if (ull == ULLONG_MAX && errno == ERANGE)
|
||||
return -1;
|
||||
else if (ull > UINT64_MAX)
|
||||
return -1;
|
||||
*out = (uint64_t)ull;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user