Skip to content

Commit

Permalink
qrouting: Fix Coverity paranoid warning
Browse files Browse the repository at this point in the history
Even if the buffer can never be overflown here thanks to the CHAR(64) DB
schema restriction, if the user were to change the DB schema by hand and
extend the column to 65+ chars, it would crash OpenSIPS, so the warning
makes some sense.

Fixes CID #211387
  • Loading branch information
liviuchircu committed Jul 9, 2020
1 parent 5df8b63 commit 70d2e8f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/qrouting/qr_load.c
Expand Up @@ -50,10 +50,15 @@ str qr_profiles_table = str_init("qr_profiles");
static inline void add_profile(qr_profile_t *prof,
const int *int_vals, char * const *str_vals, const double *double_vals)
{
int i;
int i, len;

prof->id = int_vals[INT_VALS_ID];
strncpy(prof->name, str_vals[STR_VALS_PROFILE_NAME], QR_NAME_COL_SZ + 1);

len = strlen(str_vals[STR_VALS_PROFILE_NAME]);
if (len > QR_NAME_COL_SZ)
len = QR_NAME_COL_SZ;
memcpy(prof->name, str_vals[STR_VALS_PROFILE_NAME], len);
prof->name[len] = '\0';

prof->asr1 = double_vals[DBL_VALS_WARN_ASR];
prof->ccr1 = double_vals[DBL_VALS_WARN_CCR];
Expand Down

0 comments on commit 70d2e8f

Please sign in to comment.