8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 10:43:03 +01:00

fixed bugs in server version reporting

This commit is contained in:
alexpeshkoff 2005-12-29 08:06:11 +00:00
parent dabd19d630
commit 4447d705c8
2 changed files with 17 additions and 10 deletions

View File

@ -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;

View File

@ -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<UCHAR>(value); *(ptr)++ = static_cast<UCHAR>(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 */