From fa3f0499cc1709fefaf95a6a6902651ba3961c8d Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Wed, 22 Jun 2022 15:21:31 +1200 Subject: pyglue:generate_random_[machine]_password: ValueError for bad values The actual range is 14 to 255 for machine passwords, and there is a min <= max check for both. Signed-off-by: Douglas Bagnall Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Fri Aug 26 08:59:28 UTC 2022 on sn-devel-184 --- python/pyglue.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'python') diff --git a/python/pyglue.c b/python/pyglue.c index dee3c296e03..60592874ae6 100644 --- a/python/pyglue.c +++ b/python/pyglue.c @@ -74,6 +74,11 @@ static PyObject *py_generate_random_password(PyObject *self, PyObject *args) retstr = generate_random_password(NULL, min, max); if (retstr == NULL) { + if (errno == EINVAL) { + PyErr_Format(PyExc_ValueError, + "invalid range: %d - %d", + min, max); + } return NULL; } ret = PyUnicode_FromString(retstr); @@ -104,6 +109,11 @@ static PyObject *py_generate_random_machine_password(PyObject *self, PyObject *a retstr = generate_random_machine_password(NULL, min, max); if (retstr == NULL) { + if (errno == EINVAL) { + PyErr_Format(PyExc_ValueError, + "invalid range: %d - %d", + min, max); + } return NULL; } ret = PyUnicode_FromString(retstr); -- cgit v1.2.3