pgcrypto/px.c fix

From: Marko Kreen <marko(at)l-t(dot)ee>
To: pgsql-patches(at)postgresql(dot)org
Subject: pgcrypto/px.c fix
Date: 2001-08-29 22:10:46
Message-ID: 20010830001046.A22866@l-t.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


This makes encrypt() parser more strict.

--
marko

Index: contrib/pgcrypto/px.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/contrib/pgcrypto/px.c,v
retrieving revision 1.1
diff -u -r1.1 px.c
--- contrib/pgcrypto/px.c 21 Aug 2001 01:32:01 -0000 1.1
+++ contrib/pgcrypto/px.c 21 Aug 2001 12:11:15 -0000
@@ -208,7 +208,7 @@

/* PARSER */

-static void
+static int
parse_cipher_name(char *full, char **cipher, char **pad)
{
char *p, *p2, *q;
@@ -229,14 +229,16 @@
p2 = strchr(p, ':');
if (p2 != NULL) {
*p2++ = 0;
- if (!strcmp(p, "pad")) {
+ if (!strcmp(p, "pad"))
*pad = p2;
- } else {
- elog(ERROR, "Unknown component: '%s'", p);
- }
- }
+ else
+ return -1;
+ } else
+ return -1;
+
p = q;
}
+ return 0;
}

/* provider */
@@ -255,11 +257,11 @@
buf = px_alloc(strlen(name) + 1);
strcpy(buf, name);

- parse_cipher_name(buf, &s_cipher, &s_pad);
- if (s_cipher == NULL) {
+ err = parse_cipher_name(buf, &s_cipher, &s_pad);
+ if (err) {
px_free(buf);
px_free(cx);
- return -1;
+ return err;
}

err = px_find_cipher(s_cipher, &cx->cipher);

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2001-08-29 23:30:40 Re: encoding names
Previous Message Rene Pijlman 2001-08-29 22:02:19 Re: Patch for broken JDBC's getColumn()