File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 28
28
#include "includes.h"
29
29
30
30
#include <sys/types.h>
31
+ #ifndef WINDOWS
31
32
#include <sys/mman.h>
33
+ #endif
32
34
#include <netinet/in.h>
33
35
34
36
#ifdef WITH_OPENSSL
67
69
#endif
68
70
#ifdef WINDOWS
69
71
#include <lmcons.h>
72
+ #include <Windows.h>
70
73
#endif
71
74
72
75
#include "openbsd-compat/openssl-compat.h"
@@ -774,12 +777,20 @@ sshkey_prekey_alloc(u_char **prekeyp, size_t len)
774
777
u_char * prekey ;
775
778
776
779
* prekeyp = NULL ;
780
+ #ifdef WINDOWS
781
+ prekey = VirtualAlloc (NULL , len , MEM_COMMIT | MEM_RESERVE , PAGE_READWRITE );
782
+ if (prekey == NULL ) {
783
+ return SSH_ERR_SYSTEM_ERROR ;
784
+ }
785
+ VirtualLock (prekey , len );
786
+ #else
777
787
if ((prekey = mmap (NULL , len , PROT_READ |PROT_WRITE ,
778
788
MAP_ANON |MAP_PRIVATE |PREKEY_MMAP_FLAG , -1 , 0 )) == MAP_FAILED )
779
789
return SSH_ERR_SYSTEM_ERROR ;
780
790
#if defined(MADV_DONTDUMP ) && !defined(MAP_CONCEAL ) && !defined(MAP_NOCORE )
781
791
(void )madvise (prekey , len , MADV_DONTDUMP );
782
792
#endif
793
+ #endif /* WINDOWS */
783
794
* prekeyp = prekey ;
784
795
return 0 ;
785
796
}
@@ -789,7 +800,13 @@ sshkey_prekey_free(void *prekey, size_t len)
789
800
{
790
801
if (prekey == NULL )
791
802
return ;
803
+ #ifdef WINDOWS
804
+ SecureZeroMemory (prekey , len );
805
+ VirtualUnlock (prekey , len );
806
+ VirtualFree (prekey , 0 , MEM_RELEASE );
807
+ #else
792
808
munmap (prekey , len );
809
+ #endif /* WINDOWS */
793
810
}
794
811
795
812
static void
You can’t perform that action at this time.
0 commit comments