8000 Pass msglen to avoid embedded null problem with strings · postgres/postgres@0e86672 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0e86672

Browse files
committed
Pass msglen to avoid embedded null problem with strings
1 parent a4445cf commit 0e86672

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/interfaces/libpqasn1/fe-exec-asn1.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ extern PGresult *PQexecFinish(PGconn *conn);
3232
extern bool PQexecStart(PGconn *conn);
3333

3434

35-
int PQsendASNQuery(PGconn *conn, const char *query);
36-
PGresult *PQASNexec(PGconn *conn, const char *query);
35+
int PQsendASNQuery(PGconn *conn, const char *query, const int msglen);
36+
PGresult *PQASNexec(PGconn *conn, const char *query, const int msglen);
3737
void symbol_for_ruby_pg(void);
3838

3939

@@ -48,14 +48,14 @@ void symbol_for_ruby_pg(void);
4848
* XXXXX - when is it safe to free bufferInfo / buffer?
4949
*/
5050
int
51-
PQsendASNQuery(PGconn *conn, const char *query)
51+
PQsendASNQuery(PGconn *conn, const char *query, const int msglen)
5252
{
53-
int encoding = 0;
53+
int encoding = 1;
5454
struct bufferInfo bufferInfo;
5555

5656
bufferInfo.buffer = query;
57-
bufferInfo.offset = strlen(query);
58-
bufferInfo.length = strlen(query);
57+
bufferInfo.offset = msglen;
58+
bufferInfo.length = msglen;
5959

6060
/* check the argument */
6161
if (!query)
@@ -110,11 +110,11 @@ PQsendASNQuery(PGconn *conn, const char *query)
110110
}
111111

112112
PGresult *
113-
PQASNexec(PGconn *conn, const char *query)
113+
PQASNexec(PGconn *conn, const char *query, const int msglen)
114114
{
115115
if (!PQexecStart(conn))
116116
return NULL;
117-
if (!PQsendASNQuery(conn, query))
117+
if (!PQsendASNQuery(conn, query, msglen))
118118
return NULL;
119119
return PQexecFinish(conn);
120120
}

0 commit comments

Comments
 (0)
0