Thread: pgcrypto/px.c fix
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);
Your patch has been added to the PostgreSQL unapplied patches list at: http://candle.pha.pa.us/cgi-bin/pgpatches I will try to apply it within the next 48 hours. > > 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
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