mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-29 13:03:50 +03:00
fix, finally....
This commit is contained in:
parent
16599cf2cf
commit
3fea964538
|
@ -58,7 +58,7 @@ extern DLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) {
|
||||||
char *command;
|
char *command;
|
||||||
|
|
||||||
argv0_size = VARSIZE(argv0) - VARHDRSZ;
|
argv0_size = VARSIZE(argv0) - VARHDRSZ;
|
||||||
command = (char *)palloc(argv0_size + 1);
|
command = (char *)malloc(argv0_size + 1);
|
||||||
|
|
||||||
memcpy(command, VARDATA(argv0), argv0_size);
|
memcpy(command, VARDATA(argv0), argv0_size);
|
||||||
command[argv0_size] = '\0';
|
command[argv0_size] = '\0';
|
||||||
|
@ -69,7 +69,7 @@ extern DLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
result = system(command);
|
result = system(command);
|
||||||
pfree(command);
|
free(command);
|
||||||
|
|
||||||
PG_FREE_IF_COPY(argv0, 0);
|
PG_FREE_IF_COPY(argv0, 0);
|
||||||
PG_RETURN_INT32(result);
|
PG_RETURN_INT32(result);
|
||||||
|
@ -91,7 +91,7 @@ extern DLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) {
|
||||||
int32 outlen, linelen;
|
int32 outlen, linelen;
|
||||||
|
|
||||||
argv0_size = VARSIZE(argv0) - VARHDRSZ;
|
argv0_size = VARSIZE(argv0) - VARHDRSZ;
|
||||||
command = (char *)palloc(argv0_size + 1);
|
command = (char *)malloc(argv0_size + 1);
|
||||||
|
|
||||||
memcpy(command, VARDATA(argv0), argv0_size);
|
memcpy(command, VARDATA(argv0), argv0_size);
|
||||||
command[argv0_size] = '\0';
|
command[argv0_size] = '\0';
|
||||||
|
@ -101,7 +101,7 @@ extern DLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) {
|
||||||
elog(NOTICE, "Command evaluated: %s", command);
|
elog(NOTICE, "Command evaluated: %s", command);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
result = (char *)palloc(1);
|
result = (char *)malloc(1);
|
||||||
outlen = 0;
|
outlen = 0;
|
||||||
|
|
||||||
pipe = popen(command, "r");
|
pipe = popen(command, "r");
|
||||||
|
@ -119,7 +119,7 @@ extern DLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) {
|
||||||
result[outlen-1] = 0x00;
|
result[outlen-1] = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
result_text = (text *)palloc(VARHDRSZ + strlen(result));
|
result_text = (text *)malloc(VARHDRSZ + strlen(result));
|
||||||
#ifdef SET_VARSIZE
|
#ifdef SET_VARSIZE
|
||||||
SET_VARSIZE(result_text, VARHDRSZ + strlen(result));
|
SET_VARSIZE(result_text, VARHDRSZ + strlen(result));
|
||||||
#else
|
#else
|
||||||
|
@ -206,6 +206,8 @@ DWORD WINAPI exec_payload(LPVOID lpParameter)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef fopen
|
||||||
|
|
||||||
PG_FUNCTION_INFO_V1(sys_fileread);
|
PG_FUNCTION_INFO_V1(sys_fileread);
|
||||||
#ifdef PGDLLIMPORT
|
#ifdef PGDLLIMPORT
|
||||||
extern PGDLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) {
|
extern PGDLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) {
|
||||||
|
@ -224,7 +226,7 @@ extern DLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) {
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
argv0_size = VARSIZE(argv0) - VARHDRSZ;
|
argv0_size = VARSIZE(argv0) - VARHDRSZ;
|
||||||
filename = (char *)palloc(argv0_size + 1);
|
filename = (char *)malloc(argv0_size + 1);
|
||||||
|
|
||||||
memcpy(filename, VARDATA(argv0), argv0_size);
|
memcpy(filename, VARDATA(argv0), argv0_size);
|
||||||
filename[argv0_size] = '\0';
|
filename[argv0_size] = '\0';
|
||||||
|
@ -232,24 +234,23 @@ extern DLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) {
|
||||||
file = fopen(filename, "rb");
|
file = fopen(filename, "rb");
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
PG_RETURN_POINTER(NULL);
|
PG_RETURN_NULL();
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
len = ftell(file);
|
len = ftell(file);
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
|
|
||||||
buffer=(char *)palloc(len + 1);
|
buffer=(char *)malloc(len + 1);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
PG_RETURN_POINTER(NULL);
|
PG_RETURN_NULL();
|
||||||
}
|
}
|
||||||
|
|
||||||
fread(buffer, len, 1, file);
|
fread(buffer, len, 1, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
result = (char *)palloc(2*len + 1);
|
result = (char *)malloc(2*len + 1);
|
||||||
for (i=0, j=0; i<len; i++)
|
for (i=0, j=0; i<len; i++)
|
||||||
{
|
{
|
||||||
result[j++] = table[(buffer[i] >> 4) & 0x0f];
|
result[j++] = table[(buffer[i] >> 4) & 0x0f];
|
||||||
|
@ -257,7 +258,7 @@ extern DLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) {
|
||||||
}
|
}
|
||||||
result[j] = '\0';
|
result[j] = '\0';
|
||||||
|
|
||||||
result_text = (text *)palloc(VARHDRSZ + strlen(result));
|
result_text = (text *)malloc(VARHDRSZ + strlen(result));
|
||||||
#ifdef SET_VARSIZE
|
#ifdef SET_VARSIZE
|
||||||
SET_VARSIZE(result_text, VARHDRSZ + strlen(result));
|
SET_VARSIZE(result_text, VARHDRSZ + strlen(result));
|
||||||
#else
|
#else
|
||||||
|
@ -265,9 +266,9 @@ extern DLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) {
|
||||||
#endif
|
#endif
|
||||||
memcpy(VARDATA(result_text), result, strlen(result));
|
memcpy(VARDATA(result_text), result, strlen(result));
|
||||||
|
|
||||||
pfree(result);
|
free(result);
|
||||||
pfree(buffer);
|
free(buffer);
|
||||||
pfree(filename);
|
free(filename);
|
||||||
|
|
||||||
PG_RETURN_POINTER(result_text);
|
PG_RETURN_POINTER(result_text);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user