Skip to content

Commit

Permalink
freeswitch ESL: Fix string truncation compiler warnings
Browse files Browse the repository at this point in the history
esl/src/esl.c: In function ‘esl_recv_event’:
esl/src/esl.c:1406:4: warning: ‘strncpy’ specified bound 1024 equals
destination size [-Wstringop-truncation]
    strncpy(handle->last_reply, hval, sizeof(handle->last_reply));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In function ‘esl_send_recv_timed.part.6’,
    inlined from ‘esl_send_recv_timed’ at esl/src/esl.c:1537:27:
esl/src/esl.c:1604:5: warning: ‘strncpy’ specified bound 1024 equals
destination size [-Wstringop-truncation]
     strncpy(handle->last_sr_reply, hval, sizeof(handle->last_sr_reply));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from esl/src/esl_config.c:34:
esl/src/esl_config.c: In function ‘esl_config_open_file’:
esl/src/include/esl.h:43:37: warning: ‘strncpy’ output may be truncated
copying 511 bytes from a string of length 1023 [-Wstringop-truncation]
 #define esl_copy_string(_x, _y, _z) strncpy(_x, _y, _z - 1)
                                     ^~~~~~~~~~~~~~~~~~~~~~~
esl/src/include/esl.h:44:32: note: in expansion of macro ‘esl_copy_string’
 #define esl_set_string(_x, _y) esl_copy_string(_x, _y, sizeof(_x))
                                ^~~~~~~~~~~~~~~
esl/src/esl_config.c:72:4: note: in expansion of macro ‘esl_set_string’
    esl_set_string(cfg->path, path);
    ^~~~~~~~~~~~~~

Reported by Dan Pascu

(cherry picked from commit d20f163)
  • Loading branch information
liviuchircu committed May 29, 2019
1 parent a589e10 commit 23462ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/freeswitch/esl/src/esl.c
Expand Up @@ -1403,7 +1403,7 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
hval = esl_event_get_header(revent, "reply-text");

if (!esl_strlen_zero(hval)) {
strncpy(handle->last_reply, hval, sizeof(handle->last_reply));
strncpy(handle->last_reply, hval, sizeof(handle->last_reply) - 1);
}

hval = esl_event_get_header(revent, "content-type");
Expand Down Expand Up @@ -1601,7 +1601,7 @@ ESL_DECLARE(esl_status_t) esl_send_recv_timed(esl_handle_t *handle, const char *
hval = esl_event_get_header(handle->last_sr_event, "reply-text");

if (!esl_strlen_zero(hval)) {
strncpy(handle->last_sr_reply, hval, sizeof(handle->last_sr_reply));
strncpy(handle->last_sr_reply, hval, sizeof(handle->last_sr_reply) - 1);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/freeswitch/esl/src/include/esl_config.h
Expand Up @@ -113,7 +113,7 @@ struct esl_config {
/*! FILE stream buffer to the opened file */
FILE *file;
/*! path to the file */
char path[512];
char path[1024];
/*! current category */
char category[256];
/*! current section */
Expand Down

0 comments on commit 23462ab

Please sign in to comment.