pgcrypto/px.c fix - Mailing list pgsql-patches

From Marko Kreen
Subject pgcrypto/px.c fix
Date
Msg-id 20010830001046.A22866@l-t.ee
Whole thread Raw
Responses Re: pgcrypto/px.c fix  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: pgcrypto/px.c fix  (Bruce Momjian <pgman@candle.pha.pa.us>)
List 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);

pgsql-patches by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: psql tab completion patch
Next
From: Peter Eisentraut
Date:
Subject: Re: encoding names