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

Function iscSafeConcatPath

src/common/isc.cpp:609–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607
608
609void iscSafeConcatPath(TEXT *resultString, const TEXT *appendString)
610{
611/**************************************
612 *
613 * i s c S a f e C o n c a t P a t h
614 *
615 **************************************
616 *
617 * Functional description
618 * Safely appends appendString to resultString using paths rules.
619 * resultString must be at most MAXPATHLEN size.
620 * Thread/signal safe code.
621 *
622 **************************************/
623 size_t len = strlen(resultString);
624 fb_assert(len > 0);
625
626 if (resultString[len - 1] != PathUtils::dir_sep && len < MAXPATHLEN - 1)
627 {
628 resultString[len++] = PathUtils::dir_sep;
629 resultString[len] = 0;
630 }
631
632 size_t alen = strlen(appendString);
633 if (len + alen > MAXPATHLEN - 1)
634 {
635 alen = MAXPATHLEN - 1 - len;
636 }
637
638 fb_assert(len < MAXPATHLEN);
639 fb_assert(alen < MAXPATHLEN);
640 fb_assert(len + alen < MAXPATHLEN);
641
642 memcpy(&resultString[len], appendString, alen);
643 resultString[len + alen] = 0;
644}

Callers 4

iscPrefixLockFunction · 0.85
API_ROUTINE gds__prefixFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected