From ecb44711d1403dc3c9d2554a71124a6df1dc5fd5 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 27 May 2020 21:20:43 -0400 Subject: [PATCH 1/2] Add glext.h. --- Outputs/OpenGL/OpenGL.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Outputs/OpenGL/OpenGL.hpp b/Outputs/OpenGL/OpenGL.hpp index ad5fad91a..1cef48dda 100644 --- a/Outputs/OpenGL/OpenGL.hpp +++ b/Outputs/OpenGL/OpenGL.hpp @@ -23,6 +23,7 @@ #else #define GL_GLEXT_PROTOTYPES #include +#include #endif #ifndef NDEBUG From f7c10ef9e955f91cf2eb358569abe14a04ac4ce9 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 27 May 2020 21:31:46 -0400 Subject: [PATCH 2/2] Replaces POSIX `stpncpy` with ANSI `strlen`, `memcpy` and `memset`. --- Storage/MassStorage/SCSI/Target.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Storage/MassStorage/SCSI/Target.hpp b/Storage/MassStorage/SCSI/Target.hpp index 6683dd242..e75baec4f 100644 --- a/Storage/MassStorage/SCSI/Target.hpp +++ b/Storage/MassStorage/SCSI/Target.hpp @@ -278,12 +278,12 @@ struct Executor { }; auto copy_string = [] (uint8_t *destination, const char *source, size_t length) -> void { - // Copy as much of the string as will fit, and pad with spaces. - uint8_t *end = reinterpret_cast(stpncpy(reinterpret_cast(destination), source, length)); - while(end < destination + length) { - *end = ' '; - ++end; - } + // Determine length of source and copy in as much as possible. + const auto source_length = std::min(strlen(source), length); + memcpy(destination, source, source_length); + + // Fill the rest with spaces. + memset(&destination[source_length], ' ', length - source_length); }; copy_string(&response[8], inq.vendor_identifier, 8); copy_string(&response[16], inq.product_identifier, 16);