From b895f9b3461241714458ede88cf400551bb24870 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Fri, 16 May 1997 20:22:04 +0200
Subject: [PATCH] Several fixes.

Rev: src/modules/_Crypto/pipe.c:1.8
---
 src/modules/_Crypto/pipe.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/modules/_Crypto/pipe.c b/src/modules/_Crypto/pipe.c
index 066610e8fe..076bf08f2a 100644
--- a/src/modules/_Crypto/pipe.c
+++ b/src/modules/_Crypto/pipe.c
@@ -1,5 +1,5 @@
 /*
- * $Id: pipe.c,v 1.7 1997/03/17 03:11:16 hubbe Exp $
+ * $Id: pipe.c,v 1.8 1997/05/16 18:22:04 grubba Exp $
  *
  * PIPE crypto module for Pike.
  *
@@ -82,9 +82,9 @@ static void f_create(INT32 args)
   for (i=-args; i; i++) {
     if (sp[i].type == T_OBJECT) {
       THIS->objects[args + i] = sp[i].u.object;
-      THIS->objects[i]->refs++;
+      THIS->objects[args + i]->refs++;
     } else if (sp[i].type == T_PROGRAM) {
-      THIS->objects[i] = clone_object(sp[i].u.program, 0);
+      THIS->objects[args + i] = clone_object(sp[i].u.program, 0);
     } else if (sp[i].type == T_ARRAY) {
       struct program *prog;
       INT32 n_args;
@@ -100,11 +100,11 @@ static void f_create(INT32 args)
       n_args = sp[i].u.array->size - 1;
 
       push_array_items(sp[i].u.array);	/* Pushes one arg too many */
-      THIS->objects[i] = clone_object(prog, n_args);
+      THIS->objects[args + i] = clone_object(prog, n_args);
 
       pop_stack();	/* Pop the program */
 
-      assert_is_crypto_module(THIS->objects[i]);
+      assert_is_crypto_module(THIS->objects[args + i]);
     } else {
       error("Bad argument %d to pipe->create()\n", i + args);
     }
@@ -116,11 +116,15 @@ static void f_create(INT32 args)
     int sub_size;
     int factor = 1;
 
-    safe_apply(THIS->objects[i], "block_size", 0);
+    safe_apply(THIS->objects[i], "query_block_size", 0);
     if (sp[-1].type != T_INT) {
-      error("pipe->create(): block_size() returned other than int\n");
+      error("_Crypto.pipe->create(): query_block_size() returned other than int\n"
+	    "for object #%d\n", i+1);
+    }
+    if (!(sub_size = sp[-1].u.integer)) {
+      error("_Crypto.pipe->create(): query_block_size() returned zero\n"
+	    "for object #%d\n", i+1);
     }
-    sub_size = sp[-1].u.integer;
     pop_stack();
 
     for (j=2; j <= sub_size;) {
-- 
GitLab