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

From Bruce Momjian
Subject Re: pgcrypto/px.c fix
Date
Msg-id 200109060321.f863LcD06387@candle.pha.pa.us
Whole thread Raw
In response to pgcrypto/px.c fix  (Marko Kreen <marko@l-t.ee>)
List pgsql-patches
Patch applied.  Thanks.

>
> 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);
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] [PATCH] Win32 errno a little bit safer
Next
From: Martijn van Oosterhout
Date:
Subject: Re: [GENERAL] [PATCH] Partial indices final?