Skip to content

Commit 74dde13

Browse files
committed
This makes encrypt() parser more strict.
Marko Kreen
1 parent 57040f7 commit 74dde13

File tree

1 file changed

+12
-10
lines changed
  • contrib/pgcrypto

1 file changed

+12
-10
lines changed

contrib/pgcrypto/px.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $Id: px.c,v 1.1 2001/08/21 01:32:01 momjian Exp $
29+
* $Id: px.c,v 1.2 2001/09/06 03:21:39 momjian Exp $
3030
*/
3131

3232
#include <postgres.h>
@@ -208,7 +208,7 @@ combo_free(PX_Combo *cx)
208208

209209
/* PARSER */
210210

211-
static void
211+
static int
212212
parse_cipher_name(char *full, char **cipher, char **pad)
213213
{
214214
char *p, *p2, *q;
@@ -229,14 +229,16 @@ parse_cipher_name(char *full, char **cipher, char **pad)
229229
p2 = strchr(p, ':');
230230
if (p2 != NULL) {
231231
*p2++ = 0;
232-
if (!strcmp(p, "pad")) {
232+
if (!strcmp(p, "pad"))
233233
*pad = p2;
234-
} else {
235-
elog(ERROR, "Unknown component: '%s'", p);
236-
}
237-
}
234+
else
235+
return -1;
236+
} else
237+
return -1;
238+
238239
p = q;
239240
}
241+
return 0;
240242
}
241243

242244
/* provider */
@@ -255,11 +257,11 @@ px_find_combo(const char *name, PX_Combo **res)
255257
buf = px_alloc(strlen(name) + 1);
256258
strcpy(buf, name);
257259

258-
parse_cipher_name(buf, &s_cipher, &s_pad);
259-
if (s_cipher == NULL) {
260+
err = parse_cipher_name(buf, &s_cipher, &s_pad);
261+
if (err) {
260262
px_free(buf);
261263
px_free(cx);
262-
return -1;
264+
return err;
263265
}
264266

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy