]> granicus.if.org Git - python/commitdiff
Issue #15905: Fix theoretical buffer overflow in handling of sys.argv[0],
authorChristian Heimes <christian@cheimes.de>
Mon, 22 Jul 2013 10:54:21 +0000 (12:54 +0200)
committerChristian Heimes <christian@cheimes.de>
Mon, 22 Jul 2013 10:54:21 +0000 (12:54 +0200)
prefix and exec_prefix if the operation system does not obey MAXPATHLEN.

1  2 
Misc/NEWS
Modules/getpath.c
Python/sysmodule.c

diff --cc Misc/NEWS
index f5b56ef33dfea80e609191c03575cc2efa766a82,2b28991c5142abd35c9057b2fa663c5607d98e59..26c629552f765417e4f4d37cf80ffff57c710e20
+++ b/Misc/NEWS
@@@ -10,14 -12,11 +10,17 @@@ What's New in Python 3.4.0 Alpha 1
  Core and Builtins
  -----------------
  
+ - Issue #15905: Fix theoretical buffer overflow in handling of sys.argv[0],
+   prefix and exec_prefix if the operation system does not obey MAXPATHLEN.
 +- Issue #18408: Fix many various bugs in code handling errors, especially
 +  on memory allocation failure (MemoryError).
 +
  - Issue #18344: Fix potential ref-leaks in _bufferedreader_read_all().
  
 +- Issue #18342: Use the repr of a module name when an import fails when using
 +  ``from ... import ...``.
 +
  - Issue #17872: Fix a segfault in marshal.load() when input stream returns
    more bytes than requested.
  
index 21dc8545710240f32ba0bcce910de3f8bbf25eaa,ff14fdd6cd3472ccdfcf3d6ab9237e53c561e67d..1a43150c0b24dc9ba2255a85ac9376ce9bcfa4a6
@@@ -341,9 -343,10 +343,10 @@@ search_for_prefix(wchar_t *argv0_path, 
          /* Check VPATH to see if argv0_path is in the build directory. */
          vpath = _Py_char2wchar(VPATH, NULL);
          if (vpath != NULL) {
-             wcscpy(prefix, argv0_path);
+             wcsncpy(prefix, argv0_path, MAXPATHLEN);
+             prefix[MAXPATHLEN] = L'\0';
              joinpath(prefix, vpath);
 -            PyMem_Free(vpath);
 +            PyMem_RawFree(vpath);
              joinpath(prefix, L"Lib");
              joinpath(prefix, LANDMARK);
              if (ismodule(prefix))
Simple merge