Commit 75206150 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fixed compil errors with gcc 8

parent fc19d242
Pipeline #307 failed with stage
in 0 seconds
......@@ -486,7 +486,7 @@ static void sdp_parse_payload_types(belle_sdp_media_description_t *media_desc, S
static void sdp_parse_media_crypto_parameters(belle_sdp_media_description_t *media_desc, SalStreamDescription *stream) {
belle_sip_list_t *attribute_it;
belle_sdp_attribute_t *attribute;
char tmp[257], tmp2[257], parameters[257]={0};
char tmp[257]={0}, tmp2[128]={0}, parameters[257]={0};
int valid_count = 0;
int nb;
......@@ -497,7 +497,7 @@ static void sdp_parse_media_crypto_parameters(belle_sdp_media_description_t *med
attribute=BELLE_SDP_ATTRIBUTE ( attribute_it->data );
if ( keywordcmp ( "crypto",belle_sdp_attribute_get_name ( attribute ) ) ==0 && belle_sdp_attribute_get_value ( attribute ) !=NULL ) {
nb = sscanf ( belle_sdp_attribute_get_value ( attribute ), "%d %256s inline:%256s %256s",
nb = sscanf ( belle_sdp_attribute_get_value ( attribute ), "%d %256s inline:%128s %256s",
&stream->crypto[valid_count].tag,
tmp,
tmp2, parameters );
......@@ -514,7 +514,8 @@ static void sdp_parse_media_crypto_parameters(belle_sdp_media_description_t *med
stream->crypto[valid_count].algo = MS_CRYPTO_SUITE_INVALID;
}else{
char *sep;
strncpy ( stream->crypto[valid_count].master_key, tmp2, sizeof(stream->crypto[valid_count].master_key)-1 );
strncpy ( stream->crypto[valid_count].master_key, tmp2, sizeof(stream->crypto[valid_count].master_key));
stream->crypto[valid_count].master_key[sizeof(stream->crypto[valid_count].master_key) - 1] = '\0';
sep=strchr(stream->crypto[valid_count].master_key,'|');
if (sep) *sep='\0';
stream->crypto[valid_count].algo = cs;
......@@ -566,7 +567,7 @@ static void sdp_parse_media_ice_parameters(belle_sdp_media_description_t *media_
while (3 == sscanf(ptr, "%u %s %u%n", &componentID, candidate.addr, &candidate.port, &offset)) {
if ((componentID > 0) && (componentID <= SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES)) {
SalIceRemoteCandidate *remote_candidate = &stream->ice_remote_candidates[componentID - 1];
strncpy(remote_candidate->addr, candidate.addr, sizeof(remote_candidate->addr)-1);
strncpy(remote_candidate->addr, candidate.addr, sizeof(remote_candidate->addr));
remote_candidate->port = candidate.port;
}
ptr += offset;
......@@ -814,15 +815,17 @@ static SalStreamDescription * sdp_to_stream_description(SalMediaDescription *md,
snprintf(stream->rtcp_addr, sizeof(stream->rtcp_addr), "%s", stream->rtp_addr);
attribute=belle_sdp_media_description_get_attribute(media_desc,"rtcp");
if (attribute && (value=belle_sdp_attribute_get_value(attribute))!=NULL){
char tmp[256];
char *tmp = (char *)ms_malloc0(strlen(value));
int nb = sscanf(value, "%d IN IP4 %s", &stream->rtcp_port, tmp);
if (nb == 1) {
/* SDP rtcp attribute only contains the port */
} else if (nb == 2) {
strncpy(stream->rtcp_addr, tmp, sizeof(stream->rtcp_addr)-1);
strncpy(stream->rtcp_addr, tmp, sizeof(stream->rtcp_addr));
stream->rtcp_addr[sizeof(stream->rtcp_addr) - 1] = '\0';
} else {
ms_warning("sdp has a strange a=rtcp line (%s) nb=%i", value, nb);
}
ms_free(tmp);
}
/* Read DTLS specific attributes : check is some are found in the stream description otherwise copy the session description one(which are at least set to Invalid) */
......
......@@ -149,6 +149,7 @@ bctbx_list_t * linphone_core_read_call_logs_from_config_file(LinphoneCore *lc){
tmp=lp_config_get_string(cfg,logsection,"start_date",NULL);
if (tmp) {
strncpy(cl->start_date,tmp,sizeof(cl->start_date));
cl->start_date[sizeof(cl->start_date) - 1] = '\0';
cl->start_date_time=string_to_time(cl->start_date);
}
}
......
......@@ -202,7 +202,6 @@ static time_t parse_timestamp(const char *timestamp) {
}
char * linphone_timestamp_to_rfc3339_string(time_t timestamp) {
char timestamp_str[22];
struct tm *ret;
#ifndef _WIN32
struct tm gmt;
......@@ -210,9 +209,12 @@ char * linphone_timestamp_to_rfc3339_string(time_t timestamp) {
#else
ret = gmtime(&timestamp);
#endif
snprintf(timestamp_str, sizeof(timestamp_str), "%4d-%02d-%02dT%02d:%02d:%02dZ",
int n = snprintf(0, 0, "%4d-%02d-%02dT%02d:%02d:%02dZ",
ret->tm_year + 1900, ret->tm_mon + 1, ret->tm_mday, ret->tm_hour, ret->tm_min, ret->tm_sec);
return ms_strdup(timestamp_str);
char *timestamp_str = (char *) ms_malloc(n + 1);
snprintf(timestamp_str, n + 1, "%4d-%02d-%02dT%02d:%02d:%02dZ",
ret->tm_year + 1900, ret->tm_mon + 1, ret->tm_mday, ret->tm_hour, ret->tm_min, ret->tm_sec);
return timestamp_str;
}
static LinphonePresencePerson * presence_person_new(const char *id, time_t timestamp) {
......
......@@ -149,7 +149,9 @@ LinphoneStatus sip_setup_context_login_account(SipSetupContext * ctx, const char
return -1;
}
strncpy(ctx->domain,linphone_address_get_domain(from),sizeof(ctx->domain));
ctx->domain[sizeof(ctx->domain) - 1] = '\0';
strncpy(ctx->username,linphone_address_get_username(from),sizeof(ctx->username));
ctx->username[sizeof(ctx->username) - 1] = '\0';
linphone_address_unref(from);
if (ctx->funcs->login_account)
return ctx->funcs->login_account(ctx,uri,passwd,userid);
......
......@@ -1357,8 +1357,10 @@ void MediaSessionPrivate::makeLocalMediaDescription () {
getParams()->getPrivate()->adaptToNetwork(q->getCore()->getCCore(), pingTime);
string subject = q->getParams()->getSessionName();
if (!subject.empty())
if (!subject.empty()) {
strncpy(md->name, subject.c_str(), sizeof(md->name));
md->name[sizeof(md->name) - 1] = '\0';
}
md->session_id = (oldMd ? oldMd->session_id : (rand() & 0xfff));
md->session_ver = (oldMd ? (oldMd->session_ver + 1) : (rand() & 0xfff));
md->nb_streams = (biggestDesc ? biggestDesc->nb_streams : 1);
......@@ -1370,14 +1372,18 @@ void MediaSessionPrivate::makeLocalMediaDescription () {
}
strncpy(md->addr, mediaLocalIp.c_str(), sizeof(md->addr));
md->addr[sizeof(md->addr) - 1] = '\0';
LinphoneAddress *addr = nullptr;
if (destProxy) {
addr = linphone_address_clone(linphone_proxy_config_get_identity_address(destProxy));
} else {
addr = linphone_address_new(linphone_core_get_identity(q->getCore()->getCCore()));
}
if (linphone_address_get_username(addr)) /* Might be null in case of identity without userinfo */
if (linphone_address_get_username(addr)) {/* Might be null in case of identity without userinfo */
strncpy(md->username, linphone_address_get_username(addr), sizeof(md->username));
md->username[sizeof(md->username) - 1] = '\0';
}
linphone_address_unref(addr);
int bandwidth = getParams()->getPrivate()->getDownBandwidth();
......
......@@ -134,10 +134,16 @@ string DbSession::currentTimestamp () const {
// Ugly hack but Sqlite3 does not allow table alteration where we add a date column using a default value
// of CURRENT_TIMESTAMP.
const tm &now = Utils::getTimeTAsTm(std::time(nullptr));
char buffer[22];
int n = snprintf(
0,
0,
"'%d-%02d-%02d %02d:%02d:%02d'",
now.tm_year + 1900, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec
);
char buffer[n + 1];
snprintf(
buffer,
sizeof buffer,
n+1,
"'%d-%02d-%02d %02d:%02d:%02d'",
now.tm_year + 1900, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec
);
......
......@@ -327,7 +327,10 @@ void IceAgent::updateLocalMediaDescriptionFromIce (SalMediaDescription *desc) {
}
strncpy(desc->ice_pwd, ice_session_local_pwd(iceSession), sizeof(desc->ice_pwd));
desc->ice_pwd[sizeof(desc->ice_pwd) - 1] = '\0';
strncpy(desc->ice_ufrag, ice_session_local_ufrag(iceSession), sizeof(desc->ice_ufrag));
desc->ice_ufrag[sizeof(desc->ice_ufrag) - 1] = '\0';
for (int i = 0; i < desc->nb_streams; i++) {
SalStreamDescription *stream = &desc->streams[i];
IceCheckList *cl = ice_session_check_list(iceSession, i);
......
......@@ -159,8 +159,10 @@ void StunClient::updateMediaDescription (SalMediaDescription *md) const {
audioCandidate.address == videoCandidate.address
) ||
sal_media_description_get_nb_active_streams(md) == 1
)
) {
strncpy(md->addr, audioCandidate.address.c_str(), sizeof(md->addr));
md->addr[sizeof(md->addr) - 1] = '\0';
}
} else if (md->streams[i].type == SalVideo && videoCandidate.port != 0) {
strncpy(md->streams[i].rtp_addr, videoCandidate.address.c_str(), sizeof(md->streams[i].rtp_addr));
md->streams[i].rtp_port = videoCandidate.port;
......
......@@ -211,7 +211,7 @@ static void on_report_send_remove_fields (const LinphoneCall *call, SalStreamTyp
/* Corrupt start of the report */
const char *corrupted_str = "corrupted report is corrupted";
size_t corrupted_len = strlen(corrupted_str);
strncpy(body, corrupted_str, corrupted_len);
strncpy(body, corrupted_str, corrupted_len + 1);
linphone_content_set_string_buffer((LinphoneContent *)content, body);
bctbx_free(body);
}
......
......@@ -958,6 +958,7 @@ static void linphone_conference_server_refer_received(LinphoneCore *core, const
if(refer_to_addr == NULL) return;
strncpy(method, linphone_address_get_method_param(refer_to_addr), sizeof(method));
method[sizeof(method) - 1] = '\0';
if(strcmp(method, "BYE") == 0) {
linphone_address_clean(refer_to_addr);
uri = linphone_address_as_string_uri_only(refer_to_addr);
......
......@@ -42,6 +42,7 @@ void parse_args(int argc, char *argv[]) {
exit(-1);
}
strncpy(config_file, argv[2], 1024);
config_file[sizeof(config_file) - 1] = '\0';
}
int main(int argc, char *argv[]) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment