home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.657 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  6.5 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.657
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.657
  11. Problem:    Python bindings silently truncate string values containing NUL.
  12. Solution:   Fail when a string contains NUL. (ZyX)
  13. Files:      src/if_python.c, src/if_python3.c
  14.  
  15.  
  16. *** ../vim-7.3.656/src/if_python.c    2012-09-05 18:54:37.000000000 +0200
  17. --- src/if_python.c    2012-09-05 19:02:07.000000000 +0200
  18. ***************
  19. *** 191,196 ****
  20. --- 191,197 ----
  21.   # define PyRun_SimpleString dll_PyRun_SimpleString
  22.   # define PyRun_String dll_PyRun_String
  23.   # define PyString_AsString dll_PyString_AsString
  24. + # define PyString_AsStringAndSize dll_PyString_AsStringAndSize
  25.   # define PyString_FromString dll_PyString_FromString
  26.   # define PyString_FromStringAndSize dll_PyString_FromStringAndSize
  27.   # define PyString_Size dll_PyString_Size
  28. ***************
  29. *** 288,293 ****
  30. --- 289,295 ----
  31.   static int(*dll_PyRun_SimpleString)(char *);
  32.   static PyObject *(*dll_PyRun_String)(char *, int, PyObject *, PyObject *);
  33.   static char*(*dll_PyString_AsString)(PyObject *);
  34. + static int(*dll_PyString_AsStringAndSize)(PyObject *, char **, int *);
  35.   static PyObject*(*dll_PyString_FromString)(const char *);
  36.   static PyObject*(*dll_PyString_FromStringAndSize)(const char *, PyInt);
  37.   static PyInt(*dll_PyString_Size)(PyObject *);
  38. ***************
  39. *** 406,411 ****
  40. --- 408,414 ----
  41.       {"PyRun_SimpleString", (PYTHON_PROC*)&dll_PyRun_SimpleString},
  42.       {"PyRun_String", (PYTHON_PROC*)&dll_PyRun_String},
  43.       {"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString},
  44. +     {"PyString_AsStringAndSize", (PYTHON_PROC*)&dll_PyString_AsStringAndSize},
  45.       {"PyString_FromString", (PYTHON_PROC*)&dll_PyString_FromString},
  46.       {"PyString_FromStringAndSize", (PYTHON_PROC*)&dll_PyString_FromStringAndSize},
  47.       {"PyString_Size", (PYTHON_PROC*)&dll_PyString_Size},
  48. ***************
  49. *** 578,591 ****
  50.   static int initialised = 0;
  51.   #define PYINITIALISED initialised
  52.   
  53. - /* Add conversion from PyInt? */
  54.   #define DICTKEY_GET(err) \
  55.       if (!PyString_Check(keyObject)) \
  56.       { \
  57.       PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
  58.       return err; \
  59.       } \
  60. !     key = (char_u *) PyString_AsString(keyObject);
  61.   #define DICTKEY_UNREF
  62.   #define DICTKEY_DECL
  63.   
  64. --- 581,595 ----
  65.   static int initialised = 0;
  66.   #define PYINITIALISED initialised
  67.   
  68.   #define DICTKEY_GET(err) \
  69.       if (!PyString_Check(keyObject)) \
  70.       { \
  71.       PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
  72.       return err; \
  73.       } \
  74. !     if (PyString_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \
  75. !     return err;
  76.   #define DICTKEY_UNREF
  77.   #define DICTKEY_DECL
  78.   
  79. *** ../vim-7.3.656/src/if_python3.c    2012-09-05 18:54:37.000000000 +0200
  80. --- src/if_python3.c    2012-09-05 19:02:07.000000000 +0200
  81. ***************
  82. *** 172,177 ****
  83. --- 172,178 ----
  84.   # define PyUnicode_AsEncodedString py3_PyUnicode_AsEncodedString
  85.   # undef PyBytes_AsString
  86.   # define PyBytes_AsString py3_PyBytes_AsString
  87. + # define PyBytes_AsStringAndSize py3_PyBytes_AsStringAndSize
  88.   # undef PyBytes_FromString
  89.   # define PyBytes_FromString py3_PyBytes_FromString
  90.   # define PyFloat_FromDouble py3_PyFloat_FromDouble
  91. ***************
  92. *** 273,278 ****
  93. --- 274,280 ----
  94.   static char* (*py3__PyUnicode_AsString)(PyObject *unicode);
  95.   static PyObject* (*py3_PyUnicode_AsEncodedString)(PyObject *unicode, const char* encoding, const char* errors);
  96.   static char* (*py3_PyBytes_AsString)(PyObject *bytes);
  97. + static int (*py3_PyBytes_AsStringAndSize)(PyObject *bytes, char **buffer, int *length);
  98.   static PyObject* (*py3_PyBytes_FromString)(char *str);
  99.   static PyObject* (*py3_PyFloat_FromDouble)(double num);
  100.   static double (*py3_PyFloat_AsDouble)(PyObject *);
  101. ***************
  102. *** 379,384 ****
  103. --- 381,387 ----
  104.       {"PyImport_AppendInittab", (PYTHON_PROC*)&py3_PyImport_AppendInittab},
  105.       {"_PyUnicode_AsString", (PYTHON_PROC*)&py3__PyUnicode_AsString},
  106.       {"PyBytes_AsString", (PYTHON_PROC*)&py3_PyBytes_AsString},
  107. +     {"PyBytes_AsStringAndSize", (PYTHON_PROC*)&py3_PyBytes_AsStringAndSize},
  108.       {"PyBytes_FromString", (PYTHON_PROC*)&py3_PyBytes_FromString},
  109.       {"PyFloat_FromDouble", (PYTHON_PROC*)&py3_PyFloat_FromDouble},
  110.       {"PyFloat_AsDouble", (PYTHON_PROC*)&py3_PyFloat_AsDouble},
  111. ***************
  112. *** 544,560 ****
  113.   
  114.   #define PYINITIALISED py3initialised
  115.   
  116. ! /* Add conversion from PyInt? */
  117.   #define DICTKEY_GET(err) \
  118.       if (PyBytes_Check(keyObject)) \
  119. !     key = (char_u *) PyBytes_AsString(keyObject); \
  120.       else if (PyUnicode_Check(keyObject)) \
  121.       { \
  122.       bytes = PyString_AsBytes(keyObject); \
  123.       if (bytes == NULL) \
  124.           return err; \
  125. !     key = (char_u *) PyBytes_AsString(bytes); \
  126. !     if (key == NULL) \
  127.           return err; \
  128.       } \
  129.       else \
  130. --- 547,566 ----
  131.   
  132.   #define PYINITIALISED py3initialised
  133.   
  134. ! #define DICTKEY_DECL PyObject *bytes = NULL;
  135.   #define DICTKEY_GET(err) \
  136.       if (PyBytes_Check(keyObject)) \
  137. !     { \
  138. !     if (PyBytes_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \
  139. !         return err; \
  140. !     } \
  141.       else if (PyUnicode_Check(keyObject)) \
  142.       { \
  143.       bytes = PyString_AsBytes(keyObject); \
  144.       if (bytes == NULL) \
  145.           return err; \
  146. !     if (PyBytes_AsStringAndSize(bytes, (char **) &key, NULL) == -1) \
  147.           return err; \
  148.       } \
  149.       else \
  150. ***************
  151. *** 562,573 ****
  152.       PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
  153.       return err; \
  154.       }
  155.   #define DICTKEY_UNREF \
  156.       if (bytes != NULL) \
  157.       Py_XDECREF(bytes);
  158.   
  159. - #define DICTKEY_DECL PyObject *bytes = NULL;
  160.   /*
  161.    * Include the code shared with if_python.c
  162.    */
  163. --- 568,578 ----
  164.       PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
  165.       return err; \
  166.       }
  167.   #define DICTKEY_UNREF \
  168.       if (bytes != NULL) \
  169.       Py_XDECREF(bytes);
  170.   
  171.   /*
  172.    * Include the code shared with if_python.c
  173.    */
  174. *** ../vim-7.3.656/src/version.c    2012-09-05 18:54:37.000000000 +0200
  175. --- src/version.c    2012-09-05 19:03:03.000000000 +0200
  176. ***************
  177. *** 721,722 ****
  178. --- 721,724 ----
  179.   {   /* Add new patch number below this line */
  180. + /**/
  181. +     657,
  182.   /**/
  183.  
  184. -- 
  185. Have you heard about the new Barbie doll?  It's called Divorce
  186. Barbie.  It comes with all of Ken's stuff.
  187.  
  188.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  189. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  190. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  191.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  192.