MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / xdr_cstring_with_limit

Function xdr_cstring_with_limit

src/remote/protocol.cpp:1395–1450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1393}
1394
1395static bool_t xdr_cstring_with_limit( RemoteXdr* xdrs, CSTRING* cstring, ULONG limit)
1396{
1397/**************************************
1398 *
1399 * x d r _ c s t r i n g
1400 *
1401 **************************************
1402 *
1403 * Functional description
1404 * Map a counted string structure.
1405 *
1406 **************************************/
1407 SLONG l;
1408 SCHAR trash[4];
1409 static const SCHAR filler[4] = { 0, 0, 0, 0 };
1410
1411 if (!xdr_long(xdrs, reinterpret_cast<SLONG*>(&cstring->cstr_length)))
1412 {
1413 return FALSE;
1414 }
1415
1416 // string length was USHORT in older versions
1417 fixupLength(xdrs, cstring->cstr_length);
1418
1419 switch (xdrs->x_op)
1420 {
1421 case XDR_ENCODE:
1422 if (cstring->cstr_length &&
1423 !xdrs->x_putbytes(reinterpret_cast<const SCHAR*>(cstring->cstr_address), cstring->cstr_length))
1424 {
1425 return FALSE;
1426 }
1427 l = (4 - cstring->cstr_length) & 3;
1428 if (l)
1429 return xdrs->x_putbytes(filler, l);
1430 return TRUE;
1431
1432 case XDR_DECODE:
1433 if (limit && cstring->cstr_length > limit)
1434 return FALSE;
1435 if (!alloc_cstring(xdrs, cstring))
1436 return FALSE;
1437 if (!xdrs->x_getbytes(reinterpret_cast<SCHAR*>(cstring->cstr_address), cstring->cstr_length))
1438 return FALSE;
1439 l = (4 - cstring->cstr_length) & 3;
1440 if (l)
1441 return xdrs->x_getbytes(trash, l);
1442 return TRUE;
1443
1444 case XDR_FREE:
1445 cstring->free(xdrs);
1446 return TRUE;
1447 }
1448
1449 return FALSE;
1450}
1451
1452

Callers 2

xdr_responseFunction · 0.85
xdr_cstringFunction · 0.85

Calls 6

xdr_longFunction · 0.85
fixupLengthFunction · 0.85
alloc_cstringFunction · 0.85
x_putbytesMethod · 0.45
x_getbytesMethod · 0.45
freeMethod · 0.45

Tested by

no test coverage detected