diff options
author | Guido van Rossum <guido@python.org> | 1993-11-03 15:01:26 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-11-03 15:01:26 (GMT) |
commit | e77a757094f68351f336044654cd91575c677896 (patch) | |
tree | 0c0f8f78c180d4a88c9c5ff8c26e2457b6722e28 /Modules/nismodule.c | |
parent | 78ed420314876083b4cc1739d7dbf04e4f012c03 (diff) | |
download | cpython-e77a757094f68351f336044654cd91575c677896.zip cpython-e77a757094f68351f336044654cd91575c677896.tar.gz cpython-e77a757094f68351f336044654cd91575c677896.tar.bz2 |
* nismodule.c: database keys and values can contain null bytes. be more
careful about these.
* arraymodule.c: added 8 byte swap; added 'i' format character; added
reverse() method; rename read/write to fromfile/tofile.
* config.c: Set version to 0.9.9++.
* rotormodule.c (r_rand): declare k1..k5 as unsigned longs so the shifts
will have a well-defined effect independent of word size.
* bltinmodule.c: renamed bagof() to filter().
Diffstat (limited to 'Modules/nismodule.c')
-rw-r--r-- | Modules/nismodule.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Modules/nismodule.c b/Modules/nismodule.c index 9234127..5db26f4 100644 --- a/Modules/nismodule.c +++ b/Modules/nismodule.c @@ -67,9 +67,23 @@ nis_foreach (instatus, inkey, inkeylen, inval, invallen, indata) object *indata; { if (instatus == YP_TRUE) { - inkey[inkeylen]=0; - inval[invallen]=0; - dictinsert (indata, inkey, newstringobject (inval)); + object *key = newsizedstringobject(inkey, inkeylen); + object *val = newsizedstringobject(inval, invallen); + int err; + if (key == NULL || val == NULL) { + /* XXX error -- don't know how to handle */ + err_clear(); + XDECREF(key); + XDECREF(val); + return 1; + } + err = mappinginsert(indata, key, val); + DECREF(key); + DECREF(val); + if (err != 0) { + err_clear(); + return 1; + } return 0; } return 1; @@ -82,18 +96,18 @@ nis_match (self, args) { char *match; char *domain; - int len; + int keylen, len; char *key, *map; int err; object *res; - if (!getargs(args, "(ss)", &key, &map)) + if (!getargs(args, "(s#s)", &key, &keylen, &map)) return NULL; if ((err = yp_get_default_domain(&domain)) != 0) return nis_error(err); BGN_SAVE map = nis_mapname (map); - err = yp_match (domain, map, key, strlen (key), &match, &len); + err = yp_match (domain, map, key, keylen, &match, &len); END_SAVE if (err != 0) return nis_error(err); |