Skip to content

Commit d86b6ea

Browse files
committed
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3: Fix some lengths in crypt() Conflicts: ext/standard/crypt.c
2 parents 8992da2 + e6cf7d7 commit d86b6ea

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/standard/crypt.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ PHP_FUNCTION(crypt)
199199
char *output;
200200
int needed = (sizeof(sha512_salt_prefix) - 1
201201
+ sizeof(sha512_rounds_prefix) + 9 + 1
202-
+ PHP_MAX_SALT_LEN + 1 + 43 + 1);
202+
+ salt_in_len + 1 + 86 + 1);
203203
output = emalloc(needed);
204204
salt[salt_in_len] = '\0';
205205

@@ -214,15 +214,15 @@ PHP_FUNCTION(crypt)
214214
RETVAL_STRING(output, 1);
215215
}
216216

217-
memset(output, 0, PHP_MAX_SALT_LEN + 1);
217+
memset(output, 0, needed);
218218
efree(output);
219219
} else if (salt[0]=='$' && salt[1]=='5' && salt[2]=='$') {
220220
const char sha256_salt_prefix[] = "$5$";
221221
const char sha256_rounds_prefix[] = "rounds=";
222222
char *output;
223223
int needed = (sizeof(sha256_salt_prefix) - 1
224224
+ sizeof(sha256_rounds_prefix) + 9 + 1
225-
+ PHP_MAX_SALT_LEN + 1 + 43 + 1);
225+
+ salt_in_len + 1 + 43 + 1);
226226
output = emalloc(needed);
227227
salt[salt_in_len] = '\0';
228228

@@ -237,7 +237,7 @@ PHP_FUNCTION(crypt)
237237
RETVAL_STRING(output, 1);
238238
}
239239

240-
memset(output, 0, PHP_MAX_SALT_LEN + 1);
240+
memset(output, 0, needed);
241241
efree(output);
242242
} else if (
243243
salt[0] == '$' &&

0 commit comments

Comments
 (0)