Commit 141b8982 authored by Magnus Hagander's avatar Magnus Hagander

More carefully validate xlog location string inputs

Now that we have validate_xlog_location, call it from the previously
existing functions taking xlog locatoins as a string input.

Suggested by Fujii Masao
parent bc5ac368
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
#include "utils/guc.h" #include "utils/guc.h"
#include "utils/timestamp.h" #include "utils/timestamp.h"
static void validate_xlog_location(char *str);
/* /*
* pg_start_backup: set up for taking an on-line backup dump * pg_start_backup: set up for taking an on-line backup dump
* *
...@@ -289,6 +293,8 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS) ...@@ -289,6 +293,8 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
*/ */
locationstr = text_to_cstring(location); locationstr = text_to_cstring(location);
validate_xlog_location(locationstr);
if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2) if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
...@@ -361,6 +367,8 @@ pg_xlogfile_name(PG_FUNCTION_ARGS) ...@@ -361,6 +367,8 @@ pg_xlogfile_name(PG_FUNCTION_ARGS)
locationstr = text_to_cstring(location); locationstr = text_to_cstring(location);
validate_xlog_location(locationstr);
if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2) if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment