summaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c9
-rw-r--r--src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc9
-rw-r--r--src/interfaces/libpq/fe-auth.c15
3 files changed, 22 insertions, 11 deletions
diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c b/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c
index 8d716e58a22..d3ebb0e106c 100644
--- a/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c
+++ b/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c
@@ -127,9 +127,12 @@ main(void)
{
for (j = 0; times[j]; j++)
{
- char* t;
- if (asprintf(&t, "%s %s", dates[i], times[j]) < 0)
- abort();
+ int length = strlen(dates[i])
+ + 1
+ + strlen(times[j])
+ + 1;
+ char* t = malloc(length);
+ sprintf(t, "%s %s", dates[i], times[j]);
ts1 = PGTYPEStimestamp_from_asc(t, NULL);
text = PGTYPEStimestamp_to_asc(ts1);
if (i != 19 || j != 3) /* timestamp as integer or double differ for this case */
diff --git a/src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc b/src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc
index 2a1c4a61dd9..0edf012fd11 100644
--- a/src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc
+++ b/src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc
@@ -92,9 +92,12 @@ main(void)
{
for (j = 0; times[j]; j++)
{
- char* t;
- if (asprintf(&t, "%s %s", dates[i], times[j]) < 0)
- abort();
+ int length = strlen(dates[i])
+ + 1
+ + strlen(times[j])
+ + 1;
+ char* t = malloc(length);
+ sprintf(t, "%s %s", dates[i], times[j]);
ts1 = PGTYPEStimestamp_from_asc(t, NULL);
text = PGTYPEStimestamp_to_asc(ts1);
if (i != 19 || j != 3) /* timestamp as integer or double differ for this case */
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index dfc9cfb1fbe..975f7958d11 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -420,6 +420,7 @@ pg_GSS_startup(PGconn *conn)
{
OM_uint32 maj_stat,
min_stat;
+ int maxlen;
gss_buffer_desc temp_gbuf;
if (!(conn->pghost && conn->pghost[0] != '\0'))
@@ -440,14 +441,16 @@ pg_GSS_startup(PGconn *conn)
* Import service principal name so the proper ticket can be acquired by
* the GSSAPI system.
*/
- if (asprintf((char **)&temp_gbuf.value, "%s@%s",
- conn->krbsrvname, conn->pghost) < 0)
+ maxlen = NI_MAXHOST + strlen(conn->krbsrvname) + 2;
+ temp_gbuf.value = (char *) malloc(maxlen);
+ if (!temp_gbuf.value)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("out of memory"));
+ libpq_gettext("out of memory\n"));
return STATUS_ERROR;
}
-
+ snprintf(temp_gbuf.value, maxlen, "%s@%s",
+ conn->krbsrvname, conn->pghost);
temp_gbuf.length = strlen(temp_gbuf.value);
maj_stat = gss_import_name(&min_stat, &temp_gbuf,
@@ -659,11 +662,13 @@ pg_SSPI_startup(PGconn *conn, int use_negotiate)
libpq_gettext("host name must be specified\n"));
return STATUS_ERROR;
}
- if (asprintf(&conn->sspitarget, "%s/%s", conn->krbsrvname, conn->pghost) < 0)
+ conn->sspitarget = malloc(strlen(conn->krbsrvname) + strlen(conn->pghost) + 2);
+ if (!conn->sspitarget)
{
printfPQExpBuffer(&conn->errorMessage, libpq_gettext("out of memory\n"));
return STATUS_ERROR;
}
+ sprintf(conn->sspitarget, "%s/%s", conn->krbsrvname, conn->pghost);
/*
* Indicate that we're in SSPI authentication mode to make sure that