<p>Friendly Automation <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11104">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Replace calls to strtok() with strtok_r()<br><br>strtok() uses a static buffer, making it not thread safe.<br><br>Change-Id: Icce265153e1e65adafa8849334438ab6d190e541<br>---<br>M channels/chan_sip.c<br>M pbx/pbx_dundi.c<br>M res/res_fax.c<br>3 files changed, 18 insertions(+), 13 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_sip.c b/channels/chan_sip.c</span><br><span>index e632a43..1bce57c 100644</span><br><span>--- a/channels/chan_sip.c</span><br><span>+++ b/channels/chan_sip.c</span><br><span>@@ -11637,15 +11637,16 @@</span><br><span> ast_verbose("Discarded description format %s for ID %u\n", mimeSubtype, codec);</span><br><span> }</span><br><span> } else if (!strncmp(a, red_fmtp, strlen(red_fmtp))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ char *rest;</span><br><span> /* count numbers of generations in fmtp */</span><br><span> red_cp = &red_fmtp[strlen(red_fmtp)];</span><br><span> strncpy(red_fmtp, a, 100);</span><br><span> </span><br><span> sscanf(red_cp, "%30u", (unsigned *)&red_data_pt[*red_num_gen]);</span><br><span style="color: hsl(0, 100%, 40%);">- red_cp = strtok(red_cp, "/");</span><br><span style="color: hsl(120, 100%, 40%);">+ red_cp = strtok_r(red_cp, "/", &rest);</span><br><span> while (red_cp && (*red_num_gen)++ < AST_RED_MAX_GENERATION) {</span><br><span> sscanf(red_cp, "%30u", (unsigned *)&red_data_pt[*red_num_gen]);</span><br><span style="color: hsl(0, 100%, 40%);">- red_cp = strtok(NULL, "/");</span><br><span style="color: hsl(120, 100%, 40%);">+ red_cp = strtok_r(NULL, "/", &rest);</span><br><span> }</span><br><span> red_cp = red_fmtp;</span><br><span> found = TRUE;</span><br><span>diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c</span><br><span>index f196721..f0d586d 100644</span><br><span>--- a/pbx/pbx_dundi.c</span><br><span>+++ b/pbx/pbx_dundi.c</span><br><span>@@ -2977,6 +2977,8 @@</span><br><span> db_tree = ast_db_gettree("dundi/cache", NULL);</span><br><span> ast_cli(a->fd, FORMAT2, "Number", "Context", "Expiration", "From", "Weight", "Destination (Flags)");</span><br><span> for (db_entry = db_tree; db_entry; db_entry = db_entry->next) {</span><br><span style="color: hsl(120, 100%, 40%);">+ char *rest;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if ((strncmp(db_entry->key, "/dundi/cache/hint/", 18) == 0) || ast_get_time_t(db_entry->data, &ts, 0, &length)) {</span><br><span> continue;</span><br><span> }</span><br><span>@@ -2988,10 +2990,10 @@</span><br><span> }</span><br><span> </span><br><span> ptr = db_entry->key + sizeof("/dundi/cache");</span><br><span style="color: hsl(0, 100%, 40%);">- strtok(ptr, "/");</span><br><span style="color: hsl(0, 100%, 40%);">- number = strtok(NULL, "/");</span><br><span style="color: hsl(0, 100%, 40%);">- context = strtok(NULL, "/");</span><br><span style="color: hsl(0, 100%, 40%);">- ptr = strtok(NULL, "/");</span><br><span style="color: hsl(120, 100%, 40%);">+ strtok_r(ptr, "/", &rest);</span><br><span style="color: hsl(120, 100%, 40%);">+ number = strtok_r(NULL, "/", &rest);</span><br><span style="color: hsl(120, 100%, 40%);">+ context = strtok_r(NULL, "/", &rest);</span><br><span style="color: hsl(120, 100%, 40%);">+ ptr = strtok_r(NULL, "/", &rest);</span><br><span> </span><br><span> if (*ptr != 'e') {</span><br><span> continue;</span><br><span>@@ -3069,6 +3071,8 @@</span><br><span> ast_cli(a->fd, FORMAT2, "Prefix", "Context", "Expiration", "From");</span><br><span> </span><br><span> for (db_entry = db_tree; db_entry; db_entry = db_entry->next) {</span><br><span style="color: hsl(120, 100%, 40%);">+ char *rest;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_get_time_t(db_entry->data, &ts, 0, &length)) {</span><br><span> continue;</span><br><span> }</span><br><span>@@ -3080,10 +3084,10 @@</span><br><span> }</span><br><span> </span><br><span> ptr = db_entry->key + sizeof("/dundi/cache/hint");</span><br><span style="color: hsl(0, 100%, 40%);">- src = strtok(ptr, "/");</span><br><span style="color: hsl(0, 100%, 40%);">- number = strtok(NULL, "/");</span><br><span style="color: hsl(0, 100%, 40%);">- context = strtok(NULL, "/");</span><br><span style="color: hsl(0, 100%, 40%);">- ptr = strtok(NULL, "/");</span><br><span style="color: hsl(120, 100%, 40%);">+ src = strtok_r(ptr, "/", &rest);</span><br><span style="color: hsl(120, 100%, 40%);">+ number = strtok_r(NULL, "/", &rest);</span><br><span style="color: hsl(120, 100%, 40%);">+ context = strtok_r(NULL, "/", &rest);</span><br><span style="color: hsl(120, 100%, 40%);">+ ptr = strtok_r(NULL, "/", &rest);</span><br><span> </span><br><span> if (*ptr != 'e') {</span><br><span> continue;</span><br><span>diff --git a/res/res_fax.c b/res/res_fax.c</span><br><span>index 39a7a64..7338507 100644</span><br><span>--- a/res/res_fax.c</span><br><span>+++ b/res/res_fax.c</span><br><span>@@ -807,17 +807,17 @@</span><br><span> </span><br><span> static int update_modem_bits(enum ast_fax_modems *bits, const char *value)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- char *m[5], *tok, *v = (char *)value;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *m[5], *tok, *v = (char *) value, *rest;</span><br><span> int i = 0, j;</span><br><span> </span><br><span> if (!strchr(v, ',')) {</span><br><span> m[i++] = v;</span><br><span> m[i] = NULL;</span><br><span> } else {</span><br><span style="color: hsl(0, 100%, 40%);">- tok = strtok(v, ", ");</span><br><span style="color: hsl(120, 100%, 40%);">+ tok = strtok_r(v, ", ", &rest);</span><br><span> while (tok && i < ARRAY_LEN(m) - 1) {</span><br><span> m[i++] = tok;</span><br><span style="color: hsl(0, 100%, 40%);">- tok = strtok(NULL, ", ");</span><br><span style="color: hsl(120, 100%, 40%);">+ tok = strtok_r(NULL, ", ", &rest);</span><br><span> }</span><br><span> m[i] = NULL;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11104">change 11104</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11104"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Icce265153e1e65adafa8849334438ab6d190e541 </div>
<div style="display:none"> Gerrit-Change-Number: 11104 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>