diff --git a/src/isql/isql.epp b/src/isql/isql.epp index e26ce6bb68..2346e59027 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -4443,9 +4443,6 @@ void ISQL_get_version(bool call_by_create_db) return; } - // We assume the version information provided by the server is less than 200 bytes. - char server_version[256]; - const UCHAR* p = buffer; while (*p != isc_info_end && *p != isc_info_truncated && p < buffer + sizeof(buffer)) { const UCHAR item = (UCHAR) *p++; @@ -4537,10 +4534,20 @@ void ISQL_get_version(bool call_by_create_db) } break; case isc_info_firebird_version: - strcpy(server_version, "Server: "); - strncat(server_version, (char*) &p[2], (length - 2)); - if (Version_info) { - isqlGlob.printf("%s%s", server_version, NEWLINE); + { + const char *server = "Server: "; + // We don't assume the version information provided by the server is small - + // with redirection it may be rather long. + char *server_version = (char*) malloc(strlen(server) + length); + if (server_version) { + memset(server_version, 0, strlen(server) + length); + strcpy(server_version, server); + strncat(server_version, (char*) &p[2], (length - 2)); + if (Version_info) { + isqlGlob.printf("%s%s", server_version, NEWLINE); + } + free(server_version); + } } break; diff --git a/src/remote/merge.cpp b/src/remote/merge.cpp index 3a7f1844b5..cff94ffd0f 100644 --- a/src/remote/merge.cpp +++ b/src/remote/merge.cpp @@ -28,7 +28,7 @@ #include "../remote/merge_proto.h" #include "../jrd/gds_proto.h" -#define PUT_WORD(ptr, value) {*(ptr)++ = value; *(ptr)++ = value >> 8;} +#define PUT_WORD(ptr, value) {*(ptr)++ = static_cast(value); *(ptr)++ = static_cast(value >> 8);} #define PUT(ptr, value) *(ptr)++ = value; #ifdef NOT_USED_OR_REPLACED @@ -110,7 +110,7 @@ USHORT MERGE_database_info(const UCHAR* in, out[-1] = isc_info_truncated; return 0; } - PUT_WORD(out, (UCHAR) length); + PUT_WORD(out, length); if (length) do { *out++ = *in++; @@ -185,7 +185,7 @@ static ISC_STATUS merge_setup( *in += 2; const USHORT count = 1 + *(*in)++; - PUT_WORD(*out, (UCHAR) new_length); + PUT_WORD(*out, new_length); PUT(*out, (UCHAR) count); /* Copy data portion of information sans original count */