-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[open-dice] Add a local strlen implementation for open-dice
It requires strlen() in the cbor_writer library which is not included in the OT development environment. Bug: 356532759 Signed-off-by: Tommy Chiu <tommychiu@google.com>
- Loading branch information
1 parent
a4a0908
commit 768baf2
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
third_party/open-dice/Add-a-local-strlen-implementation.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
From 1a2ead40e2e15ca058882ad86f4ac32e5c5b6177 Mon Sep 17 00:00:00 2001 | ||
From: Tommy Chiu <tommychiu@google.com> | ||
Date: Thu, 17 Oct 2024 13:23:43 +0800 | ||
Subject: [PATCH] Add a local strlen implementation | ||
|
||
Not all developing environments have access to strlen. | ||
--- | ||
src/cbor_writer.c | 8 +++++++- | ||
1 file changed, 7 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/src/cbor_writer.c b/src/cbor_writer.c | ||
index 6c70129..c473543 100644 | ||
--- a/src/cbor_writer.c | ||
+++ b/src/cbor_writer.c | ||
@@ -30,6 +30,12 @@ enum CborType { | ||
CBOR_TYPE_SIMPLE = 7, | ||
}; | ||
|
||
+static unsigned long _strlen(const char* in) { | ||
+ unsigned long ret; | ||
+ for (ret = 0; *in++; ret++); | ||
+ return ret; | ||
+} | ||
+ | ||
static bool CborWriteWouldOverflowCursor(size_t size, struct CborOut* out) { | ||
return size > SIZE_MAX - out->cursor; | ||
} | ||
@@ -127,7 +133,7 @@ uint8_t* CborAllocBstr(size_t data_size, struct CborOut* out) { | ||
} | ||
|
||
void CborWriteTstr(const char* str, struct CborOut* out) { | ||
- CborWriteStr(CBOR_TYPE_TSTR, strlen(str), str, out); | ||
+ CborWriteStr(CBOR_TYPE_TSTR, _strlen(str), str, out); | ||
} | ||
|
||
char* CborAllocTstr(size_t size, struct CborOut* out) { | ||
-- | ||
2.47.0.rc1.288.g06298d1525-goog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters