Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(5216)

Delta Between Two Patch Sets: Modules/posixmodule.c

Issue 13703: Hash collision security issue
Left Patch Set: Created 1 year, 3 months ago
Right Patch Set: Created 1 year, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Modules/main.c ('k') | Objects/bytesobject.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 1
2 /* POSIX module implementation */ 2 /* POSIX module implementation */
3 3
4 /* This file is also used for Windows NT/MS-Win and OS/2. In that case the 4 /* This file is also used for Windows NT/MS-Win and OS/2. In that case the
5 module actually calls itself 'nt' or 'os2', not 'posix', and a few 5 module actually calls itself 'nt' or 'os2', not 'posix', and a few
6 functions are either unimplemented or implemented differently. The source 6 functions are either unimplemented or implemented differently. The source
7 assumes that for Windows NT, the macro 'MS_WINDOWS' is defined independent 7 assumes that for Windows NT, the macro 'MS_WINDOWS' is defined independent
8 of the compiler used. Different compilers define their own feature 8 of the compiler used. Different compilers define their own feature
9 test macro, e.g. '__BORLANDC__' or '_MSC_VER'. For OS/2, the compiler 9 test macro, e.g. '__BORLANDC__' or '_MSC_VER'. For OS/2, the compiler
10 independent macro PYOS_OS2 should be defined. On OS/2 the default 10 independent macro PYOS_OS2 should be defined. On OS/2 the default
(...skipping 4004 matching lines...) Expand 10 before | Expand all | Expand 10 after
4015 PyObject *result = NULL; 4015 PyObject *result = NULL;
4016 4016
4017 #ifdef NGROUPS_MAX 4017 #ifdef NGROUPS_MAX
4018 #define MAX_GROUPS NGROUPS_MAX 4018 #define MAX_GROUPS NGROUPS_MAX
4019 #else 4019 #else
4020 /* defined to be 16 on Solaris7, so this should be a small number */ 4020 /* defined to be 16 on Solaris7, so this should be a small number */
4021 #define MAX_GROUPS 64 4021 #define MAX_GROUPS 64
4022 #endif 4022 #endif
4023 gid_t grouplist[MAX_GROUPS]; 4023 gid_t grouplist[MAX_GROUPS];
4024 4024
4025 /* On MacOSX getgroups(2) can return more than MAX_GROUPS results 4025 /* On MacOSX getgroups(2) can return more than MAX_GROUPS results
4026 * This is a helper variable to store the intermediate result when 4026 * This is a helper variable to store the intermediate result when
4027 * that happens. 4027 * that happens.
4028 * 4028 *
4029 * To keep the code readable the OSX behaviour is unconditional, 4029 * To keep the code readable the OSX behaviour is unconditional,
4030 * according to the POSIX spec this should be safe on all unix-y 4030 * according to the POSIX spec this should be safe on all unix-y
4031 * systems. 4031 * systems.
4032 */ 4032 */
4033 gid_t* alt_grouplist = grouplist; 4033 gid_t* alt_grouplist = grouplist;
4034 int n; 4034 int n;
4035 4035
(...skipping 2938 matching lines...) Expand 10 before | Expand all | Expand 10 after
6974 if (codeset != NULL && codeset[0] != 0) 6974 if (codeset != NULL && codeset[0] != 0)
6975 return PyUnicode_FromString(codeset); 6975 return PyUnicode_FromString(codeset);
6976 } 6976 }
6977 #endif 6977 #endif
6978 Py_INCREF(Py_None); 6978 Py_INCREF(Py_None);
6979 return Py_None; 6979 return Py_None;
6980 } 6980 }
6981 6981
6982 PyDoc_STRVAR(posix_urandom__doc__, 6982 PyDoc_STRVAR(posix_urandom__doc__,
6983 "urandom(n) -> str\n\n\ 6983 "urandom(n) -> str\n\n\
6984 Return n pseudo-random bytes."); 6984 Return n random bytes suitable for cryptographic use.");
6985 6985
6986 static PyObject * 6986 static PyObject *
6987 posix_urandom(PyObject *self, PyObject *args) 6987 posix_urandom(PyObject *self, PyObject *args)
6988 { 6988 {
6989 Py_ssize_t size; 6989 Py_ssize_t size;
6990 PyObject *result; 6990 PyObject *result;
6991 int ret; 6991 int ret;
6992 6992
6993 /* Read arguments */ 6993 /* Read arguments */
6994 if (!PyArg_ParseTuple(args, "n:urandom", &size)) 6994 if (!PyArg_ParseTuple(args, "n:urandom", &size))
6995 return NULL; 6995 return NULL;
6996 if (size < 0) 6996 if (size < 0)
6997 return PyErr_Format(PyExc_ValueError, 6997 return PyErr_Format(PyExc_ValueError,
6998 "negative argument not allowed"); 6998 "negative argument not allowed");
6999 result = PyBytes_FromStringAndSize(NULL, size); 6999 result = PyBytes_FromStringAndSize(NULL, size);
7000 if (result == NULL) 7000 if (result == NULL)
7001 return NULL; 7001 return NULL;
7002 7002
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
7699 7699
7700 7700
7701 #endif /* __APPLE__ */ 7701 #endif /* __APPLE__ */
7702 return m; 7702 return m;
7703 7703
7704 } 7704 }
7705 7705
7706 #ifdef __cplusplus 7706 #ifdef __cplusplus
7707 } 7707 }
7708 #endif 7708 #endif
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7