From af4f7083ea92931a07e47995eb2bc2a348c577ed Mon Sep 17 00:00:00 2001 From: Ramya Darapuneni Date: Thu, 3 Nov 2022 15:33:42 +0530 Subject: [PATCH 1/3] Fix build on machines with modern flex This is to address pull request https://github.com/Xilinx/bootgen/pull/20 --- FlexLexer.h | 8 +++----- bif.yy.cpp | 2 +- bifscanner.h | 2 +- cmdoptions.yy.cpp | 2 +- cmdoptionsscanner.h | 2 +- reginit.yy.cpp | 2 +- reginitscanner.h | 2 +- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/FlexLexer.h b/FlexLexer.h index b115b5d..a06fb21 100755 --- a/FlexLexer.h +++ b/FlexLexer.h @@ -33,15 +33,15 @@ // // If you want to create multiple lexer classes, you use the -P flag // to rename each yyFlexLexer to some other xxFlexLexer. You then -// include in your other sources once per lexer class: +// include "FlexLexer.h" in your other sources once per lexer class: // // #undef yyFlexLexer // #define yyFlexLexer xxFlexLexer -// #include +// #include "FlexLexer.h" // // #undef yyFlexLexer // #define yyFlexLexer zzFlexLexer -// #include +// #include "FlexLexer.h" // ... #ifndef __FLEX_LEXER_H @@ -204,5 +204,3 @@ class yyFlexLexer : public FlexLexer { #endif // yyFlexLexer || ! yyFlexLexerOnce - -// 67d7842dbbe25473c3c32b93c0da8047785f30d78e8a024de1b57352245f9689 diff --git a/bif.yy.cpp b/bif.yy.cpp index 5e357d1..8f652bc 100644 --- a/bif.yy.cpp +++ b/bif.yy.cpp @@ -379,7 +379,7 @@ typedef unsigned char YY_CHAR; #define yytext_ptr yytext -#include +#include "FlexLexer.h" int yyFlexLexer::yywrap() { return 1; } int yyFlexLexer::yylex() diff --git a/bifscanner.h b/bifscanner.h index a6ec9e4..ded78da 100755 --- a/bifscanner.h +++ b/bifscanner.h @@ -28,7 +28,7 @@ #if ! defined(yyFlexLexerOnce) #undef yyFlexLexer #define yyFlexLexer bifFlexLexer -#include +#include "FlexLexer.h" #endif // Override the interface for yylex since we namespaced it diff --git a/cmdoptions.yy.cpp b/cmdoptions.yy.cpp index d8fd6ce..1484981 100644 --- a/cmdoptions.yy.cpp +++ b/cmdoptions.yy.cpp @@ -379,7 +379,7 @@ typedef unsigned char YY_CHAR; #define yytext_ptr yytext -#include +#include "FlexLexer.h" int yyFlexLexer::yywrap() { return 1; } int yyFlexLexer::yylex() diff --git a/cmdoptionsscanner.h b/cmdoptionsscanner.h index a48af09..e02c1f1 100755 --- a/cmdoptionsscanner.h +++ b/cmdoptionsscanner.h @@ -29,7 +29,7 @@ #undef yyFlexLexer #define yyFlexLexer reginitFlexLexer -#include +#include "FlexLexer.h" #endif // Override the interface for yylex since we namespaced it diff --git a/reginit.yy.cpp b/reginit.yy.cpp index 8422867..ff088f9 100644 --- a/reginit.yy.cpp +++ b/reginit.yy.cpp @@ -379,7 +379,7 @@ typedef unsigned char YY_CHAR; #define yytext_ptr yytext -#include +#include "FlexLexer.h" int yyFlexLexer::yywrap() { return 1; } int yyFlexLexer::yylex() diff --git a/reginitscanner.h b/reginitscanner.h index 4e78af9..23177be 100755 --- a/reginitscanner.h +++ b/reginitscanner.h @@ -29,7 +29,7 @@ #undef yyFlexLexer #define yyFlexLexer reginitFlexLexer -#include +#include "FlexLexer.h" #endif // Override the interface for yylex since we namespaced it From 1795f18361caf1536d76ffe40ae3cb66e212b020 Mon Sep 17 00:00:00 2001 From: Ramya Darapuneni Date: Fri, 24 Feb 2023 15:32:24 +0530 Subject: [PATCH 2/3] Replacing myrand() with rand() Fix for https://github.com/Xilinx/bootgen/issues/22 --- encryption.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/encryption.cpp b/encryption.cpp index 6495bae..6a7072a 100755 --- a/encryption.cpp +++ b/encryption.cpp @@ -319,7 +319,7 @@ static uint32_t GetRandomValue(uint32_t maxValue) do { - returnValue = (myrand() / (int)(((unsigned)RAND_MAX + 1) / maxValue)); + returnValue = (rand() / (int)(((unsigned)RAND_MAX + 1) / maxValue)); } while (returnValue > maxValue); return returnValue; @@ -642,4 +642,4 @@ void AesGcmEncryptionContext::AesGcm256Decrypt(unsigned char* gcm_pt, int& pt_le EVP_CIPHER_CTX_free(ctx); pt_len = outlen + tmplen; -} \ No newline at end of file +} From 12552dfdf20cfc96c3317300d25ac4dea712f8a5 Mon Sep 17 00:00:00 2001 From: Hannes Date: Wed, 5 Jul 2023 10:45:43 +0200 Subject: [PATCH 3/3] Fix error output for 32 bit elf headers The error puts out the header size for 64-bit elf files when parsing a 32-bit elf file. --- elftools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elftools.cpp b/elftools.cpp index 7674e39..eeb4b4a 100755 --- a/elftools.cpp +++ b/elftools.cpp @@ -129,7 +129,7 @@ ElfFormat32::ElfFormat32(uint8_t* start) /* Basic ELF checks */ if(ELFHdrEntrySize() != sizeof(Elf32_Ehdr)) { - LOG_DEBUG(DEBUG_STAMP, "ELF Header size wrong - %d, actual size - %d", ELFHdrEntrySize(), sizeof(Elf64_Ehdr)); + LOG_DEBUG(DEBUG_STAMP, "ELF Header size wrong - %d, actual size - %d", ELFHdrEntrySize(), sizeof(Elf32_Ehdr)); LOG_ERROR("ELF Parsing Error !!!\n Wrong Header Size"); }