summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2002-11-04 23:21:09 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2002-11-04 23:21:09 (GMT)
commit662390681e94fd4437ee000d23d042a0135aa234 (patch)
tree2641030b4caae66461b25cc8062bee371750d9c3
parent72a8a3b2b8b4f47696cba9505baa7840c03dd45c (diff)
downloadcpython-662390681e94fd4437ee000d23d042a0135aa234.zip
cpython-662390681e94fd4437ee000d23d042a0135aa234.tar.gz
cpython-662390681e94fd4437ee000d23d042a0135aa234.tar.bz2
SF #633013, Fix NIS causing interpreter core dump
Prevent the lengths passed to PyString_FromStringAndSize() from being negative in some cases.
-rw-r--r--Modules/nismodule.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/nismodule.c b/Modules/nismodule.c
index f66e9a1..0a38ee8 100644
--- a/Modules/nismodule.c
+++ b/Modules/nismodule.c
@@ -85,8 +85,10 @@ nis_foreach (int instatus, char *inkey, int inkeylen, char *inval,
int err;
if (indata->fix) {
- inkeylen--;
- invallen--;
+ if (inkeylen > 0 && inkey[inkeylen-1] == '\0')
+ inkeylen--;
+ if (invallen > 0 && inval[invallen-1] == '\0')
+ invallen--;
}
key = PyString_FromStringAndSize(inkey, inkeylen);
val = PyString_FromStringAndSize(inval, invallen);