GCC12: Fixes for 16+

Most issues were in stringfields and had to do with comparing
a pointer to an constant/interned string with NULL.  Since the
string was a constant, a pointer to it could never be NULL so
the comparison was always "true".  gcc now complains about that.

There were also a few issues where determining if there was
enough space for a memcpy or s(n)printf which were fixed
by defining some of the involved variables as "volatile".

There were also a few other miscellaneous fixes.

ASTERISK-30044

Change-Id: Ia081ca1bcfb329df6487c4660aaf1944309eb570
This commit is contained in:
George Joseph
2022-05-03 06:57:58 -06:00
parent 184c95dc01
commit c0612ccc28
12 changed files with 74 additions and 46 deletions

View File

@@ -370,7 +370,13 @@ int ast_stun_handle_packet(int s, struct sockaddr_in *src, unsigned char *data,
st.username ? st.username : "<none>");
if (st.username) {
append_attr_string(&attr, STUN_USERNAME, st.username, &resplen, &respleft);
snprintf(combined, sizeof(combined), "%16s%16s", st.username + 16, st.username);
/*
* For Google Voice, the stun username is made up of the local
* and remote usernames, each being fixed at 16 bytes. We have
* to swap the two at this point.
*/
snprintf(combined, 17, "%16s", st.username + 16);
snprintf(combined + 16, 17, "%16s", st.username);
} else {
combined[0] = '\0';
}