8
8
9
9
#include <config.h>
10
10
11
+ #include <alloca.h>
11
12
#include <errno.h>
12
13
#include <limits.h>
13
14
#include <readpassphrase.h>
14
15
#include <stddef.h>
15
- #include <stdlib.h>
16
16
#include <string.h>
17
17
18
18
#include "alloc/malloc.h"
19
19
#include "attr.h"
20
-
21
- #if WITH_LIBBSD == 0
22
- #include "freezero.h"
23
- #endif /* WITH_LIBBSD */
20
+ #include "string/memset/memzero.h"
24
21
25
22
26
23
// Similar to getpass(3), but free of its problems.
27
24
#define agetpass (prompt ) agetpass_(prompt, RPP_REQUIRE_TTY)
28
25
#define agetpass_stdin () agetpass_(NULL, RPP_STDIN)
29
26
30
- #define agetpass_ (...) getpass_(MALLOC (PASS_MAX + 2, char ), __VA_ARGS__)
27
+ #define agetpass_ (...) getpass_(alloca (PASS_MAX + 2), __VA_ARGS__)
31
28
32
29
33
30
inline void erase_pass (char * pass );
@@ -40,9 +37,6 @@ getpass_(char pass[PASS_MAX + 2], const char *prompt, int flags)
40
37
{
41
38
size_t len ;
42
39
43
- if (pass == NULL )
44
- return NULL ;
45
-
46
40
/*
47
41
* Since we want to support passwords upto PASS_MAX, we need
48
42
* PASS_MAX bytes for the password itself, and one more byte for
@@ -63,15 +57,15 @@ getpass_(char pass[PASS_MAX + 2], const char *prompt, int flags)
63
57
return pass ;
64
58
65
59
fail :
66
- freezero (pass , PASS_MAX + 2 );
60
+ memzero (pass , PASS_MAX + 2 );
67
61
return NULL ;
68
62
}
69
63
70
64
71
65
inline void
72
66
erase_pass (char * pass )
73
67
{
74
- freezero (pass , PASS_MAX + 2 );
68
+ memzero (pass , PASS_MAX + 2 );
75
69
}
76
70
77
71
0 commit comments