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

Side by Side Diff: Modules/selectmodule.c

Issue 2599: python - fix buffer overflows in unicode processing and elsewhere SVN Base: http://svn.python.org/view/*checkout*/python/trunk/
Patch Set: Created 1 year, 4 months ago , Downloaded from: http://bugs.python.org/file10825/issue2620-gps02-patch.txt
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* select - Module containing unix select(2) call. 1 /* select - Module containing unix select(2) call.
2 Under Unix, the file descriptors are small integers. 2 Under Unix, the file descriptors are small integers.
3 Under Win32, select only exists for sockets, and sockets may 3 Under Win32, select only exists for sockets, and sockets may
4 have any value except INVALID_SOCKET. 4 have any value except INVALID_SOCKET.
5 Under BeOS, we suffer the same dichotomy as Win32; sockets can be anything 5 Under BeOS, we suffer the same dichotomy as Win32; sockets can be anything
6 >= 0. 6 >= 0.
7 */ 7 */
8 8
9 #include "Python.h" 9 #include "Python.h"
10 #include <structmember.h> 10 #include <structmember.h>
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 /* Update the malloc'ed array of pollfds to match the dictionary 343 /* Update the malloc'ed array of pollfds to match the dictionary
344 contained within a pollObject. Return 1 on success, 0 on an error. 344 contained within a pollObject. Return 1 on success, 0 on an error.
345 */ 345 */
346 346
347 static int 347 static int
348 update_ufd_array(pollObject *self) 348 update_ufd_array(pollObject *self)
349 { 349 {
350 Py_ssize_t i, pos; 350 Py_ssize_t i, pos;
351 PyObject *key, *value; 351 PyObject *key, *value;
352 struct pollfd *old_ufds = self->ufds;
352 353
353 self->ufd_len = PyDict_Size(self->dict); 354 self->ufd_len = PyDict_Size(self->dict);
354 » PyMem_Resize(self->ufds, struct pollfd, self->ufd_len); 355 » PyMem_RESIZE(self->ufds, struct pollfd, self->ufd_len);
355 if (self->ufds == NULL) { 356 if (self->ufds == NULL) {
357 self->ufds = old_ufds;
356 PyErr_NoMemory(); 358 PyErr_NoMemory();
357 return 0; 359 return 0;
358 } 360 }
359 361
360 i = pos = 0; 362 i = pos = 0;
361 while (PyDict_Next(self->dict, &pos, &key, &value)) { 363 while (PyDict_Next(self->dict, &pos, &key, &value)) {
362 self->ufds[i].fd = PyInt_AsLong(key); 364 self->ufds[i].fd = PyInt_AsLong(key);
363 self->ufds[i].events = (short)PyInt_AsLong(value); 365 self->ufds[i].events = (short)PyInt_AsLong(value);
364 i++; 366 i++;
365 } 367 }
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 1874
1873 /* NETDEV filter flags */ 1875 /* NETDEV filter flags */
1874 #ifdef EVFILT_NETDEV 1876 #ifdef EVFILT_NETDEV
1875 PyModule_AddIntConstant(m, "KQ_NOTE_LINKUP", NOTE_LINKUP); 1877 PyModule_AddIntConstant(m, "KQ_NOTE_LINKUP", NOTE_LINKUP);
1876 PyModule_AddIntConstant(m, "KQ_NOTE_LINKDOWN", NOTE_LINKDOWN); 1878 PyModule_AddIntConstant(m, "KQ_NOTE_LINKDOWN", NOTE_LINKDOWN);
1877 PyModule_AddIntConstant(m, "KQ_NOTE_LINKINV", NOTE_LINKINV); 1879 PyModule_AddIntConstant(m, "KQ_NOTE_LINKINV", NOTE_LINKINV);
1878 #endif 1880 #endif
1879 1881
1880 #endif /* HAVE_KQUEUE */ 1882 #endif /* HAVE_KQUEUE */
1881 } 1883 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r497