diff --git a/LICENSE b/LICENSE index 14f0ef9..08a75e4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 DarkRIDDeR +Copyright (c) 2019-23 DarkRiDDeR, n8sh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/dub.sdl b/dub.sdl index a4cc58f..aae1699 100644 --- a/dub.sdl +++ b/dub.sdl @@ -1,6 +1,6 @@ name "zero-memory" description "This is a function implementation SecureZeroMemory in D programming language" license "DarkRiDDeR" -copyright "Copyright © 2019, DarkRiDDeR" +copyright "Copyright (c) 2019-23 DarkRiDDeR, n8sh" license "MIT License" targetType "library" \ No newline at end of file diff --git a/src/zero_memory/package.d b/src/zero_memory/package.d index 7481d68..15b9014 100644 --- a/src/zero_memory/package.d +++ b/src/zero_memory/package.d @@ -1,7 +1,7 @@ /* The MIT License (MIT) -Copyright (c) 2019 DarkRiDDeR +Copyright (c) 2019-23 DarkRiDDeR, n8sh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -45,7 +45,7 @@ pure nothrow @nogc mov RCX, length; iter: xor RBX, RBX; - mov [RDX], RBX; + mov [RDX], BL; inc RDX; loop iter; } @@ -60,7 +60,7 @@ pure nothrow @nogc mov ECX, length; iter: xor EBX, EBX; - mov [EDX], EBX; + mov [EDX], BL; inc EDX; loop iter; } @@ -126,4 +126,16 @@ unittest i2 = [8, 5, 99, 5, 99]; secureZeroMemory(cast(void[])i2); assert(i == i2); + + // Verify that secureZeroMemory doesn't have a buffer overrun. + ubyte[17] array; + array[] = 1; + ubyte[] slice = array[1..$-1]; + secureZeroMemory(slice); + // Slice should be 0. + foreach (b; slice) + assert(b == 0); + // Bytes outside slice should be 1. + assert(array[0] == 1); + assert(array[$-1] == 1); } \ No newline at end of file