Show More
@@ -696,22 +696,22 b' static int sha1hash(char hash[20], const' | |||
|
696 | 696 | return 0; |
|
697 | 697 | } |
|
698 | 698 | |
|
699 | #define MAXENCODE 4096 * 3 | |
|
700 | ||
|
699 | 701 | static PyObject *hashencode(const char *src, Py_ssize_t len) |
|
700 | 702 | { |
|
701 | const Py_ssize_t baselen = (len - 5) * 3; | |
|
702 | #ifndef _MSC_VER | |
|
703 | /* alloca is surprisingly slow, so avoid when possible */ | |
|
704 | char dired[baselen]; | |
|
705 | char lowered[baselen]; | |
|
706 | char auxed[baselen]; | |
|
707 | #else | |
|
708 | char *dired = alloca(baselen); | |
|
709 | char *lowered = alloca(baselen); | |
|
710 | char *auxed = alloca(baselen); | |
|
711 | #endif | |
|
712 | Py_ssize_t dirlen, lowerlen, auxlen; | |
|
703 | char dired[MAXENCODE]; | |
|
704 | char lowered[MAXENCODE]; | |
|
705 | char auxed[MAXENCODE]; | |
|
706 | Py_ssize_t dirlen, lowerlen, auxlen, baselen; | |
|
713 | 707 | char sha[20]; |
|
714 | 708 | |
|
709 | baselen = (len - 5) * 3; | |
|
710 | if (baselen >= MAXENCODE) { | |
|
711 | PyErr_SetString(PyExc_ValueError, "string too long"); | |
|
712 | return NULL; | |
|
713 | } | |
|
714 | ||
|
715 | 715 | dirlen = _encodedir(dired, baselen, src, len); |
|
716 | 716 | if (sha1hash(sha, dired, dirlen - 1) == -1) |
|
717 | 717 | return NULL; |
General Comments 0
You need to be logged in to leave comments.
Login now