From 952de6648abd3d7192f97f3335c016df365b3ae0 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Thu, 19 May 2011 12:38:31 +0200 Subject: [PATCH] Leave off trailing \0s --- python/_libvserver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/_libvserver.c b/python/_libvserver.c index d433d4b..f675971 100644 --- a/python/_libvserver.c +++ b/python/_libvserver.c @@ -591,6 +591,7 @@ pyvserver_get_vhi_name(PyObject UNUSED *self, PyObject *args) xid_t xid; vc_uts_type type; char val[65]; + int i; if (!PyArg_ParseTuple(args, "Ii", &xid, &type)) return NULL; @@ -598,7 +599,10 @@ pyvserver_get_vhi_name(PyObject UNUSED *self, PyObject *args) if (vc_get_vhi_name(xid, type, val, sizeof(val)) == -1) return PyErr_SetFromErrno(PyExc_OSError); - return Py_BuildValue("s#", val, sizeof(val)); + for (i = sizeof(val); i > 0 && val[i - 1] == '\0'; i--) + ; + + return Py_BuildValue("s#", val, i); } static PyObject * -- 1.8.1.5