From 07d75753d59419ea6ba9ee3bd930e0aa8e7e7fd5 Mon Sep 17 00:00:00 2001 From: Nick Bofferding Date: Fri, 20 Oct 2017 21:13:34 -0500 Subject: 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 Tested-by: Jenkins Server Reviewed-by: Marshall J. Wilks Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Reviewed-by: Stephen M. Cprek Tested-by: FSP CI Jenkins Reviewed-by: William G. Hoffa --- src/lib/string.C | 22 ------------------- src/lib/string_utils.C | 59 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 23 deletions(-) (limited to 'src/lib') 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(a-begin)+1 *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; +} + -- cgit v1.2.1