@@ -199,7 +199,7 @@ PHP_FUNCTION(crypt)
199
199
char * output ;
200
200
int needed = (sizeof (sha512_salt_prefix ) - 1
201
201
+ sizeof (sha512_rounds_prefix ) + 9 + 1
202
- + PHP_MAX_SALT_LEN + 1 + 43 + 1 );
202
+ + salt_in_len + 1 + 86 + 1 );
203
203
output = emalloc (needed );
204
204
salt [salt_in_len ] = '\0' ;
205
205
@@ -214,15 +214,15 @@ PHP_FUNCTION(crypt)
214
214
RETVAL_STRING (output , 1 );
215
215
}
216
216
217
- memset (output , 0 , PHP_MAX_SALT_LEN + 1 );
217
+ memset (output , 0 , needed );
218
218
efree (output );
219
219
} else if (salt [0 ]== '$' && salt [1 ]== '5' && salt [2 ]== '$' ) {
220
220
const char sha256_salt_prefix [] = "$5$" ;
221
221
const char sha256_rounds_prefix [] = "rounds=" ;
222
222
char * output ;
223
223
int needed = (sizeof (sha256_salt_prefix ) - 1
224
224
+ sizeof (sha256_rounds_prefix ) + 9 + 1
225
- + PHP_MAX_SALT_LEN + 1 + 43 + 1 );
225
+ + salt_in_len + 1 + 43 + 1 );
226
226
output = emalloc (needed );
227
227
salt [salt_in_len ] = '\0' ;
228
228
@@ -237,7 +237,7 @@ PHP_FUNCTION(crypt)
237
237
RETVAL_STRING (output , 1 );
238
238
}
239
239
240
- memset (output , 0 , PHP_MAX_SALT_LEN + 1 );
240
+ memset (output , 0 , needed );
241
241
efree (output );
242
242
} else if (
243
243
salt [0 ] == '$' &&
0 commit comments