summaryrefslogtreecommitdiff
path: root/Modules/nismodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-11-03 15:01:26 +0000
committerGuido van Rossum <guido@python.org>1993-11-03 15:01:26 +0000
commit7677437b46942de102910bdefb7c87a03c573682 (patch)
tree38889030702209b048742fce7d0bba5083b5f103 /Modules/nismodule.c
parent1d582c97ce650573f3c34e25958ae2ca517f1fc1 (diff)
downloadcpython-7677437b46942de102910bdefb7c87a03c573682.tar.gz
* 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.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/Modules/nismodule.c b/Modules/nismodule.c
index 92341273c5..5db26f4fec 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);