09.09.2021 11:51, Jiří Činčura wrote:
Hi,

I'm trying to read response for `fb_info_creation_timestamp_tz`. Timezone piece. But I'm getting some weird data. The whole buffer is `139, 12, 0, 8, 232, 0, 0, 10, 71, 173, 16, 216, 103, 147, 0, 1`, thus if I'm counting correctly the `216, 103, 147, 0` should be timezone data, which is weird.

  Time zone should be at bytes 8 - 11 (counting from zero), i.e. '71, 173, 16, 
216', AFAIU

The `dbb->dbb_creation_date.time_zone` from 
[inf.cpp](https://github.com/FirebirdSQL/firebird/blob/master/src/jrd/inf.cpp#L557) is 
`ISC_USHORT`, hence `USHORT`, hence `unsigned short`. The `INF_convert` would use 
`put_vax_long` and eventually `memcpy(p, &value, sizeof(SLONG));`.

  The code you mention is buggy:

                case fb_info_creation_timestamp_tz:
                        length = 
INF_convert(dbb->dbb_creation_date.utc_timestamp.timestamp_date, p);
                        p += length;
                        length += 
INF_convert(dbb->dbb_creation_date.utc_timestamp.timestamp_time, p);
                        p += length;
                        length += INF_convert(dbb->dbb_creation_date.time_zone, 
p);
                        break;

  Second "p += length" is wrong as "length" here is not a length of just added 
value (timestamp_time)
but sum of length of both added values (timestamp_date and timestamp_time). Thus, correct 
"time_zone"
bytes (8-11) contains some garbage.

  It should be something like:

                case fb_info_creation_timestamp_tz:
                        length = 
INF_convert(dbb->dbb_creation_date.utc_timestamp.timestamp_date, p);
                        length += 
INF_convert(dbb->dbb_creation_date.utc_timestamp.timestamp_time, p + length);
                        length += INF_convert(dbb->dbb_creation_date.time_zone, 
p + length);
                        p += length;
                        break;

>
> But how can `ISC_USHORT` end up in `216, 103, 147, 0`?

  The buffer you got contains garbage, if I'm right.

Regards,
Vlad


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to