diff -cprN head/src/backend/utils/adt/genfile.c work/src/backend/utils/adt/genfile.c *** head/src/backend/utils/adt/genfile.c 2010-01-04 09:10:26.638773000 +0900 --- work/src/backend/utils/adt/genfile.c 2010-01-04 10:47:07.492409763 +0900 *************** *** 22,27 **** --- 22,28 ---- #include "catalog/pg_type.h" #include "funcapi.h" + #include "mb/pg_wchar.h" #include "miscadmin.h" #include "postmaster/syslogger.h" #include "storage/fd.h" *************** pg_read_file(PG_FUNCTION_ARGS) *** 131,136 **** --- 132,140 ---- (errcode_for_file_access(), errmsg("could not read file \"%s\": %m", filename))); + /* Make sure the input is valid */ + pg_verifymbstr(VARDATA(buf), nbytes, false); + SET_VARSIZE(buf, nbytes + VARHDRSZ); FreeFile(file);