MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / ospCopyStrToBuffer

Function ospCopyStrToBuffer

modules/osp/sipheader.c:142–165  ·  view source on GitHub ↗

* Copy str to buffer and check overflow * param source Str * param buffer Buffer * param bufsize Size of buffer */

Source from the content-addressed store, hash-verified

140 * param bufsize Size of buffer
141 */
142void ospCopyStrToBuffer(
143 str* source,
144 char* buffer,
145 int bufsize)
146{
147 int copybytes;
148
149 if (source->len >= bufsize) {
150 LM_ERR("buffer for copying '%.*s' is too small, will copy the first '%d' bytes\n",
151 source->len,
152 source->s,
153 bufsize - 1);
154 copybytes = bufsize;
155 } else {
156 copybytes = source->len + 1;
157 }
158
159 if (source->s != NULL) {
160 strncpy(buffer, source->s, copybytes);
161 buffer[copybytes - 1] = '\0';
162 } else {
163 buffer[0] = '\0';
164 }
165}
166
167/*
168 * Get local egress address

Callers 15

ospReportUsageFromCookieFunction · 0.85
ospRequestRoutingFunction · 0.85
ospGetLocalAddressFunction · 0.85
ospGetFromDisplayFunction · 0.85
ospGetFromUserFunction · 0.85
ospGetFromFunction · 0.85
ospGetToDisplayFunction · 0.85
ospGetToUserFunction · 0.85
ospGetToHostFunction · 0.85
ospGetToFunction · 0.85
ospGetPaiUserFunction · 0.85
ospGetPaiHostFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected