* Copy str to buffer and check overflow * param source Str * param buffer Buffer * param bufsize Size of buffer */
| 140 | * param bufsize Size of buffer |
| 141 | */ |
| 142 | void 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 |
no outgoing calls
no test coverage detected