resolved the stack over flow errors reported by Johann Zuschlag.
2) Support {oj syntax for 71. servers.
Oid new_adtid;
Int2 new_adtsize;
Int4 new_atttypmod = -1;
- char new_field_name[MAX_MESSAGE_LEN + 1];
+ /* MAX_COLUMN_LEN may be sufficient but for safety */
+ char new_field_name[2 * MAX_COLUMN_LEN + 1];
SocketClass *sock;
ConnInfo *ci;
for (lf = 0; lf < new_num_fields; lf++)
{
- SOCK_get_string(sock, new_field_name, MAX_MESSAGE_LEN);
+ SOCK_get_string(sock, new_field_name, 2 * MAX_COLUMN_LEN);
new_adtid = (Oid) SOCK_get_int(sock, 4);
new_adtsize = (Int2) SOCK_get_int(sock, 2);
for (lf = 0; lf < num_fields; lf++)
{
if (self->name[lf])
+ {
free(self->name[lf]);
+ self->name[lf] = NULL;
+ }
}
/* Safe to call even if null */
- free(self->name);
- free(self->adtid);
- free(self->adtsize);
- free(self->display_size);
-
- free(self->atttypmod);
+ self->num_fields = 0;
+ if (self->name)
+ free(self->name);
+ self->name = NULL;
+ if (self->adtid)
+ free(self->adtid);
+ self->adtid = NULL;
+ if (self->adtsize)
+ free(self->adtsize);
+ self->adtsize = NULL;
+ if (self->display_size)
+ free(self->display_size);
+ self->display_size = NULL;
+
+ if (self->atttypmod)
+ free(self->atttypmod);
+ self->atttypmod = NULL;
}
void
self->num_fields = new_num_fields;
self->name = (char **) malloc(sizeof(char *) * self->num_fields);
+ memset(self->name, 0, sizeof(char *) * self->num_fields);
self->adtid = (Oid *) malloc(sizeof(Oid) * self->num_fields);
self->adtsize = (Int2 *) malloc(sizeof(Int2) * self->num_fields);
self->display_size = (Int2 *) malloc(sizeof(Int2) * self->num_fields);
char swallow;
int id;
SocketClass *sock = self->sock;
- static char msgbuffer[MAX_MESSAGE_LEN + 1];
- char cmdbuffer[MAX_MESSAGE_LEN + 1]; /* QR_set_command() dups
+ /* ERROR_MSG_LENGTH is suffcient */
+ static char msgbuffer[ERROR_MSG_LENGTH + 1];
+ char cmdbuffer[ERROR_MSG_LENGTH + 1]; /* QR_set_command() dups
* this string so dont
* need static */
{
case 'A': /* Asynchronous Messages are ignored */
(void) SOCK_get_int(sock, 4); /* id of notification */
- SOCK_get_string(sock, msgbuffer, MAX_MESSAGE_LEN);
+ SOCK_get_string(sock, msgbuffer, ERROR_MSG_LENGTH);
/* name of the relation the message comes from */
break;
case 'C': /* portal query command, no tuples
* returned */
/* read in the return message from the backend */
- SOCK_get_string(sock, cmdbuffer, MAX_MESSAGE_LEN);
+ SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
if (SOCK_get_errcode(sock) != 0)
{
self->errornumber = CONNECTION_NO_RESPONSE;
return res; /* instead of NULL. Zoltan */
case 'P': /* get the Portal name */
- SOCK_get_string(sock, msgbuffer, MAX_MESSAGE_LEN);
+ SOCK_get_string(sock, msgbuffer, ERROR_MSG_LENGTH);
break;
case 'T': /* Tuple results start here */
result_in = qi ? qi->result_in : NULL;
c,
done;
SocketClass *sock = self->sock;
- static char msgbuffer[MAX_MESSAGE_LEN + 1];
+ /* ERROR_MSG_LENGTH is sufficient */
+ static char msgbuffer[ERROR_MSG_LENGTH + 1];
int i;
mylog("send_function(): conn=%u, fnid=%d, result_is_int=%d, nargs=%d\n", self, fnid, result_is_int, nargs);
if ((strcmp(key, "d") == 0) ||
(strcmp(key, "t") == 0) ||
+ (strcmp(key, "oj") == 0) || /* {oj syntax support for 7.1 servers */
(strcmp(key, "ts") == 0))
{
/* Literal; return the escape part as-is */
stmt->data_at_exec = -1;
for (i = 0; i < stmt->parameters_allocated; i++)
{
+ Int4 *pcVal = stmt->parameters[i].used;
+ if (pcVal && (*pcVal == SQL_DATA_AT_EXEC || *pcVal <= SQL_LEN_DATA_AT_EXEC_OFFSET))
+ stmt->parameters[i].data_at_exec = TRUE;
+ else
+ stmt->parameters[i].data_at_exec = FALSE;
/* Check for data at execution parameters */
if (stmt->parameters[i].data_at_exec == TRUE)
{
int end_tuple = self->rowset_size + self->base;
char corrected = FALSE;
TupleField *the_tuples = self->backend_tuples;
- static char msgbuffer[MAX_MESSAGE_LEN + 1];
- char cmdbuffer[MAX_MESSAGE_LEN + 1]; /* QR_set_command() dups
+ /* ERROR_MSG_LENGTH is sufficient */
+ static char msgbuffer[ERROR_MSG_LENGTH + 1];
+ char cmdbuffer[ERROR_MSG_LENGTH + 1]; /* QR_set_command() dups
* this string so dont
* need static */
char fetch[128];
case 'C': /* End of tuple list */
- SOCK_get_string(sock, cmdbuffer, MAX_MESSAGE_LEN);
+ SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
QR_set_command(self, cmdbuffer);
mylog("end of tuple list -- setting inUse to false: this = %u\n", self);