]> granicus.if.org Git - postgresql/commitdiff
More carefully validate xlog location string inputs
authorMagnus Hagander <magnus@hagander.net>
Sun, 4 Mar 2012 11:24:09 +0000 (12:24 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sun, 4 Mar 2012 11:25:47 +0000 (12:25 +0100)
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

src/backend/access/transam/xlogfuncs.c

index 08b5724b97e7b47617b30c2af8691cf2ef554287..f3c8a09c2aa4826549a3e06cfc29e495d72c2ceb 100644 (file)
 #include "utils/guc.h"
 #include "utils/timestamp.h"
 
+
+static void validate_xlog_location(char *str);
+
+
 /*
  * pg_start_backup: set up for taking an on-line backup dump
  *
@@ -289,6 +293,8 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
         */
        locationstr = text_to_cstring(location);
 
+       validate_xlog_location(locationstr);
+
        if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -361,6 +367,8 @@ pg_xlogfile_name(PG_FUNCTION_ARGS)
 
        locationstr = text_to_cstring(location);
 
+       validate_xlog_location(locationstr);
+
        if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),