summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNick Bofferding <bofferdn@us.ibm.com>2017-10-20 21:13:34 -0500
committerWilliam G. Hoffa <wghoffa@us.ibm.com>2017-11-03 09:45:20 -0400
commit07d75753d59419ea6ba9ee3bd930e0aa8e7e7fd5 (patch)
tree78633da60312ff8cfd54807f787219036e976621 /src/lib
parent47f275a6bd3b2104a82d9786122afd6fe25f05de (diff)
downloadtalos-hostboot-07d75753d59419ea6ba9ee3bd930e0aa8e7e7fd5.tar.gz
talos-hostboot-07d75753d59419ea6ba9ee3bd930e0aa8e7e7fd5.zip
Secure Boot: Enforce PNOR section component IDs
- In secure mode, bootloader will enforce that HBB component ID is set - In secure mode, Hostboot will enforce that PNOR component IDs are set Change-Id: I04f3bbc45417b3229003c56e1083e1fc31c01cd7 RTC: 179422 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/48711 Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Marshall J. Wilks <mjwilks@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Reviewed-by: Stephen M. Cprek <smcprek@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/string.C22
-rw-r--r--src/lib/string_utils.C59
2 files changed, 58 insertions, 23 deletions
diff --git a/src/lib/string.C b/src/lib/string.C
index 004345372..43e46f6cc 100644
--- a/src/lib/string.C
+++ b/src/lib/string.C
@@ -78,28 +78,6 @@ extern "C" char* strcpy(char* d, const char* s)
} while(1);
}
-extern "C" char* strncpy(char* d, const char* s, size_t l)
-{
- char* d1 = d;
- size_t len = 0;
-
- do
- {
- if (len++ >= l) break;
- *d1 = *s;
- if (*s == '\0') break;
- d1++; s++;
- } while(1);
-
- // pad the remainder
- while( len < l )
- {
- d1[len++] = '\0';
- }
-
- return d;
-}
-
extern "C" int strcmp(const char* a, const char* b)
{
while((*a != '\0') && (*b != '\0'))
diff --git a/src/lib/string_utils.C b/src/lib/string_utils.C
index 79a8bf709..27d9228fb 100644
--- a/src/lib/string_utils.C
+++ b/src/lib/string_utils.C
@@ -120,4 +120,61 @@ extern "C" int memcmp(const void *p1, const void *p2, size_t len)
}
return 0;
-} \ No newline at end of file
+}
+
+extern "C" int strncmp(const char* a, const char* b, size_t l)
+{
+ if(l==0)
+ {
+ return 0;
+ }
+
+ const char* begin=a;
+ while( (*a != '\0') && (*b != '\0')
+ && (static_cast<size_t>(a-begin)+1<l) )
+ {
+ if (*a == *b)
+ {
+ a++; b++;
+ }
+ else
+ {
+ return (*a > *b) ? 1 : -1;
+ }
+ }
+ if (*a == *b)
+ {
+ return 0;
+ }
+ if (*a == '\0')
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+extern "C" char* strncpy(char* d, const char* s, size_t l)
+{
+ char* d1 = d;
+ size_t len = 0;
+
+ do
+ {
+ if (len++ >= l) break;
+ *d1 = *s;
+ if (*s == '\0') break;
+ d1++; s++;
+ } while(1);
+
+ // pad the remainder
+ while( len < l )
+ {
+ d1[len++] = '\0';
+ }
+
+ return d;
+}
+
OpenPOWER on IntegriCloud