mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 06:43:03 +01:00
Better report truncated paths than to crash due to malformed parameter block.
This commit is contained in:
parent
ab144dea61
commit
5bff502eac
@ -5558,7 +5558,7 @@ TEXT* JRD_num_attachments(TEXT* const buf, USHORT buf_len, USHORT flag,
|
|||||||
|
|
||||||
ULONG num_att = 0;
|
ULONG num_att = 0;
|
||||||
ULONG drive_mask = 0L;
|
ULONG drive_mask = 0L;
|
||||||
USHORT total = 0;
|
ULONG total = 0;
|
||||||
Firebird::HalfStaticArray<Firebird::PathName, 8> dbFiles;
|
Firebird::HalfStaticArray<Firebird::PathName, 8> dbFiles;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -5578,8 +5578,8 @@ TEXT* JRD_num_attachments(TEXT* const buf, USHORT buf_len, USHORT flag,
|
|||||||
|
|
||||||
if (flag == JRD_info_drivemask)
|
if (flag == JRD_info_drivemask)
|
||||||
{
|
{
|
||||||
PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
|
const PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
|
||||||
for (jrd_file* files = pageSpace->file; files; files = files->fil_next)
|
for (const jrd_file* files = pageSpace->file; files; files = files->fil_next)
|
||||||
ExtractDriveLetter(files->fil_string, &drive_mask);
|
ExtractDriveLetter(files->fil_string, &drive_mask);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -5590,7 +5590,7 @@ TEXT* JRD_num_attachments(TEXT* const buf, USHORT buf_len, USHORT flag,
|
|||||||
{
|
{
|
||||||
if (!dbFiles.exist(dbb->dbb_filename))
|
if (!dbFiles.exist(dbb->dbb_filename))
|
||||||
dbFiles.add(dbb->dbb_filename);
|
dbFiles.add(dbb->dbb_filename);
|
||||||
total += sizeof(USHORT) + dbb->dbb_filename.length();
|
total += sizeof(USHORT) + MIN(dbb->dbb_filename.length(), 255);
|
||||||
|
|
||||||
for (const Attachment* attach = dbb->dbb_attachments; attach;
|
for (const Attachment* attach = dbb->dbb_attachments; attach;
|
||||||
attach = attach->att_next)
|
attach = attach->att_next)
|
||||||
@ -5648,14 +5648,16 @@ TEXT* JRD_num_attachments(TEXT* const buf, USHORT buf_len, USHORT flag,
|
|||||||
last db name
|
last db name
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
fb_assert(num_dbs < MAX_USHORT);
|
||||||
*lbufp++ = (TEXT) num_dbs;
|
*lbufp++ = (TEXT) num_dbs;
|
||||||
*lbufp++ = (TEXT) (num_dbs >> 8);
|
*lbufp++ = (TEXT) (num_dbs >> 8);
|
||||||
|
|
||||||
for (size_t n = 0; n < num_dbs; ++n) {
|
for (size_t n = 0; n < num_dbs; ++n) {
|
||||||
*lbufp++ = (TEXT) dbFiles[n].length();
|
const USHORT dblen = MIN(dbFiles[n].length(), 255);
|
||||||
*lbufp++ = (TEXT) (dbFiles[n].length() >> 8);
|
*lbufp++ = (TEXT) dblen;
|
||||||
memcpy(lbufp, dbFiles[n].c_str(), dbFiles[n].length());
|
*lbufp++ = (TEXT) (dblen >> 8);
|
||||||
lbufp += dbFiles[n].length();
|
memcpy(lbufp, dbFiles[n].c_str(), dblen);
|
||||||
|
lbufp += dblen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user