@@ -87,6 +87,15 @@ static void test_issue_17(void) {
87
87
assert (memcmp (buf1 , buf2 , sizeof (buf1 )) != 0 );
88
88
}
89
89
90
+ static void test_issue_22 (void ) {
91
+ uint8_t buf1 [20 ] = {}, buf2 [sizeof (buf1 )] = {};
92
+ const int ret1 = randombytes (buf1 , sizeof (buf1 ));
93
+ const int ret2 = randombytes (buf2 , sizeof (buf2 ));
94
+ assert (ret1 == 0 );
95
+ assert (ret2 == 0 );
96
+ assert (memcmp (buf1 , buf2 , sizeof (buf1 )) != 0 );
97
+ }
98
+
90
99
// ======== Mock OS functions to simulate uncommon behavior ========
91
100
92
101
#if defined(__linux__ ) && defined(SYS_getrandom )
@@ -112,6 +121,10 @@ int __wrap_ioctl(int fd, int code, int* ret) {
112
121
errno = ENOTTY ;
113
122
return -1 ;
114
123
}
124
+ if (current_test == test_issue_17 ) {
125
+ errno = ENOSYS ;
126
+ return -1 ;
127
+ }
115
128
return __real_ioctl (fd , code , ret );
116
129
}
117
130
#endif /* defined(__linux__) && !defined(SYS_getrandom) */
@@ -133,8 +146,10 @@ int main(void) {
133
146
#endif /* defined(__linux__) && defined(SYS_getrandom) */
134
147
#if defined(__linux__ ) && !defined(SYS_getrandom )
135
148
RUN_TEST (test_issue_17 )
149
+ RUN_TEST (test_issue_22 )
136
150
#else
137
151
SKIP_TEST (test_issue_17 )
152
+ SKIP_TEST (test_issue_22 )
138
153
#endif /* defined(__linux__) && !defined(SYS_getrandom) */
139
154
return 0 ;
140
155
}
0 commit comments