]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix for FSCORE-40
authorMichael Jerris <mike@jerris.com>
Fri, 3 Aug 2007 21:29:01 +0000 (21:29 +0000)
committerMichael Jerris <mike@jerris.com>
Fri, 3 Aug 2007 21:29:01 +0000 (21:29 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5566 d0543943-73ff-0310-b7d9-9358b9ac24b2

14 files changed:
src/mod/applications/mod_commands/mod_commands.c
src/mod/applications/mod_dptools/mod_dptools.c
src/mod/endpoints/mod_iax/mod_iax.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_presence.c
src/mod/event_handlers/mod_event_socket/mod_event_socket.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c
src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
src/switch.c
src/switch_core.c
src/switch_ivr_originate.c
src/switch_xml.c

index 5aa6dbd1da169f0cfdc796a5113b6dca5a1b50ad..756bb91dc4dcabd60cdfe661aed5e21127e8dee0 100644 (file)
@@ -1059,7 +1059,8 @@ static int show_as_xml_callback(void *pArg, int argc, char **argv, char **column
        }
 
        snprintf(id, sizeof(id), "%d", holder->rows);
-       switch_xml_set_attr_d(row, "row_id", id);
+
+       switch_xml_set_attr(switch_xml_set_flag(row, SWITCH_XML_DUP), strdup("row_id"), strdup(id));
 
        for(x = 0; x < argc; x++) {
                char *name = columnNames[x];
@@ -1229,7 +1230,8 @@ SWITCH_STANDARD_API(show_function)
                        char count[50];
                        char *xmlstr;
                        snprintf(count, sizeof(count), "%d", holder.count);
-                       switch_xml_set_attr_d(holder.xml, "row_count", count);
+
+                       switch_xml_set_attr(switch_xml_set_flag(holder.xml, SWITCH_XML_DUP), strdup("row_count"), strdup(count));
                        xmlstr = switch_xml_toxml(holder.xml);
 
                        if (xmlstr) {
index 4e3d660b0fd6b2e34b6eb161a61432aac2bec669..3b30b9a6ef55ea8a0fa22028715f0533820634a0 100644 (file)
@@ -724,7 +724,9 @@ SWITCH_STANDARD_APP(fax_detect_session_function)
 SWITCH_STANDARD_APP(system_session_function)
 {
     switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing command: %s\n",data);
-    system(data);
+    if(!system(data)) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Failed to execute command: %s\n",data);
+       }
 }
 
 SWITCH_STANDARD_APP(tone_detect_session_function)
index 9a535bc988d7277b281184796d86800b406ed858..6929c6985269a3fbc2cba3c41d1f1a6fff737124 100644 (file)
@@ -278,8 +278,8 @@ static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *i
                        char pref_str[256] = "(";
 
                        for (x = 0; x < len; x++) {
-                               strncat(pref_str, ast2str(prefs[x]), sizeof(pref_str));
-                               strncat(pref_str, x == len - 1 ? ")" : ",", sizeof(pref_str));
+                               strncat(pref_str, ast2str(prefs[x]), sizeof(pref_str)-1);
+                               strncat(pref_str, x == len - 1 ? ")" : ",", sizeof(pref_str)-1);
                        }
 
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Codec Prefs Detected: %s\n", pref_str);
index df6d001c3a4178beadccd0b03a06f39e3efee236..f0f10044b2c6436b9a72c603dfa8a63e1b7f4f59 100644 (file)
@@ -1785,7 +1785,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
        }
        switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 
-       if (!switch_strlen_zero(key)) {
+       if (*key != '\0') {
                tech_pvt->key = switch_core_session_strdup(session, key);
        }
 
index d1660fb907f04c49c1e8a9b65a1f2f0c8eea5e52..cf24d369ca41d9d80e3e4ecd89e1022456a5869b 100644 (file)
@@ -582,10 +582,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
        }
 
        nua_invite(tech_pvt->nh,
-                          TAG_IF(!switch_strlen_zero(rpid), SIPTAG_HEADER_STR(rpid)),
-                          TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)),
+                          TAG_IF(*rpid != '\0', SIPTAG_HEADER_STR(rpid)),
+                          TAG_IF(*alert_info != '\0', SIPTAG_HEADER_STR(alert_info)),
                           TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-                          TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)),
+                          TAG_IF(*max_forwards != '\0', SIPTAG_MAX_FORWARDS_STR(max_forwards)),
                           SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
                           SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
                           SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
@@ -600,7 +600,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
 
 void sofia_glue_do_xfer_invite(switch_core_session_t *session)
 {
-       char rpid[1024];
        private_object_t *tech_pvt;
        switch_channel_t *channel = NULL;
        switch_caller_profile_t *caller_profile;
@@ -630,7 +629,6 @@ void sofia_glue_do_xfer_invite(switch_core_session_t *session)
                nua_handle_bind(tech_pvt->nh2, tech_pvt->sofia_private);
 
                nua_invite(tech_pvt->nh2,
-                                  TAG_IF(rpid, SIPTAG_HEADER_STR(rpid)),
                                   SIPTAG_CONTACT_STR(tech_pvt->profile->url),
                                   SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
                                   SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE), SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), TAG_END());
@@ -1092,7 +1090,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
 
                if (!strcasecmp(a->a_name, "sendonly")) {
                        sendonly = 1;
-               } else if (!strcasecmp(a->a_name, "sendrecv")) {\r
+               } else if (!strcasecmp(a->a_name, "sendrecv")) {
                        sendonly = 0;
                } else if (!strcasecmp(a->a_name, "ptime")) {
                        dptime = atoi(a->a_value);
index f5353e2583661c56397d7be1cbaf1cebad6898bf..7133c9a8736bc21fe4d0a856540812c3ab721ddb 100644 (file)
@@ -1033,7 +1033,7 @@ void sofia_presence_handle_sip_i_message(int status,
                                if ((ci = switch_loadable_module_get_chat_interface(proto))) {
                                        ci->chat_send(SOFIA_CHAT_PROTO, from_addr, to_addr, "", msg, full_from);
                                } else {
-                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto ? proto : "(none)");
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
                                }
 
                        }
index 6ed4ba7bc92bc9da4431367e4ad15a44624cb25e..c42572208aa56dc6bea8b7eb670a5e2b0b91b7bc 100644 (file)
@@ -1065,7 +1065,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t * thread, void *obj
                                switch_clear_flag_locked(listener, LFLAG_RUNNING);
                                goto done;
                        }
-                       if (!switch_strlen_zero(reply)) {
+                       if (*reply != '\0') {
                                snprintf(buf, sizeof(buf), "Content-Type: command/reply\nReply-Text: %s\n\n", reply);
                                len = strlen(buf);
                                switch_socket_send(listener->sock, buf, &len);
@@ -1094,7 +1094,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t * thread, void *obj
                        break;
                }
 
-               if (!switch_strlen_zero(reply)) {
+               if (*reply != '\0') {
                        snprintf(buf, sizeof(buf), "Content-Type: command/reply\nReply-Text: %s\n\n", reply);
                        len = strlen(buf);
                        switch_socket_send(listener->sock, buf, &len);
index 7327e33c9de99c42b1689ec5886e1647a5319792..564c9d882589b40173d920aea35a9b5e1592b008 100644 (file)
@@ -715,7 +715,7 @@ static switch_status_t sm_load_file(char *filename)
 
 }
 
-static switch_status_t sm_load_module(char *dir, char *fname)
+static switch_status_t sm_load_module(const char *dir, const char *fname)
 {
        switch_size_t len = 0;
        char *path;
@@ -788,7 +788,7 @@ static switch_status_t load_modules(void)
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
                                        continue;
                                }
-                               sm_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val);
+                               sm_load_module(SWITCH_GLOBAL_dirs.mod_dir, val);
                                count++;
                        }
                }
@@ -1964,7 +1964,9 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data)
        register unsigned int realsize = (unsigned int) (size * nmemb);
        struct config_data *config_data = data;
 
-       write(config_data->fd, ptr, realsize);
+       if ((write(config_data->fd, ptr, realsize) != (int)realsize)) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to write all bytes!\n");
+       }
        return realsize;
 }
 
index 2c38e576ea6af92266f3311c5d56b0774248b0bd..172727fb5ddfdbcb2c34af307c7bef5666fbdaec 100644 (file)
@@ -180,7 +180,10 @@ static JSBool js_email(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
                        close(ifd);
                }
                snprintf(buf, B64BUFFLEN, "/bin/cat %s | /usr/sbin/sendmail -tf \"%s\" %s", filename, from, to);
-               system(buf);
+               if(!system(buf)) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to execute command: %s\n",buf);
+               }
+
                unlink(filename);
 
 
index c09ed1e9f0a56cc3817a4aa400dd88606ebd99c0..e2d20b371a524a67fc09d5c26d52888e0248c6ed 100644 (file)
@@ -327,12 +327,12 @@ static xmlrpc_value *freeswitch_man(xmlrpc_env * const envP, xmlrpc_value * cons
        if (action) {
                if (switch_core_management_exec(relative_oid, action, buf, sizeof(buf)) == SWITCH_STATUS_SUCCESS) {
                        if (action == SMA_SET) {
-                               if (switch_strlen_zero(buf)) {
+                               if (*buf != '\0') {
                                        snprintf(buf, sizeof(buf), "OK\n");
                                }
                        }
                } else {
-                       if (switch_strlen_zero(buf)) {
+                       if (*buf != '\0') {
                                snprintf(buf, sizeof(buf), "ERROR\n");
                        }
                }
index 4f4c3f00aa15a6448c5f74cba83c0ec9ef0faabb..cc083d06a20fd4616c8274bafcf46316e6bd9727 100644 (file)
@@ -96,7 +96,9 @@ static int freeswitch_kill_background()
        }
 
        /* pull the pid from the file */
-       fscanf(f, "%d", &pid);
+       if(fscanf(f, "%d", &pid)!=1) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"Unable to get the pid!\n");
+       }
 
        /* if we have a valid pid */
        if (pid > 0) {
index 9d23f5b5a5ae0b6fbf9308accd0e752c4534f54c..1a95703e14816454bf3a233079f87ecde1208b29 100644 (file)
@@ -355,7 +355,9 @@ SWITCH_DECLARE(int32_t) set_high_priority(void)
 #ifdef WIN32
        SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
 #else
-       nice(-10);
+       if(nice(-10)!= -10) {\r
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not set nice level\n");\r
+       }\r
 #endif
 
 #define USE_MLOCKALL
index 9b2fc24e0b4e8c29e41880af6f52cf85635ce6dd..58d9ee53411a2f1ced6083581966406391588f67 100644 (file)
@@ -373,7 +373,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                fail_on_single_reject = 1;
        }
 
-       if ((!switch_strlen_zero(file)) && (!strcmp(file, "undef"))) {
+       if ((*file != '\0') && (!strcmp(file, "undef"))) {
                *file = '\0';
        }
 
index 64c75be7a5e192b25d6f1bd044a85f241e806a29..18fd51009aa793ae3f79de0dc93f7168a486d423 100644 (file)
@@ -966,12 +966,16 @@ static int preprocess(const char *file, int write_fd, int rlevel)
                        }
                }
 
-               if ((cmd = strstr(bp, "<!--#"))) {
-                       write(write_fd, bp, (unsigned) (cmd - bp));
+               if ((cmd = strstr(bp, "<!--#"))) {\r
+                       if(write(write_fd, bp, (unsigned) (cmd - bp)) != (cmd - bp)) {\r
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");\r
+                       }\r
                        if ((e = strstr(cmd, "-->"))) {
                                *e = '\0';
-                               e += 3;
-                               write(write_fd, e, (unsigned) strlen(e));
+                               e += 3;\r
+                               if(write(write_fd, e, (unsigned) strlen(e)) != (int) strlen(e)) {\r
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");\r
+                               }\r
                        } else {
                                ml++;
                        }
@@ -1027,8 +1031,11 @@ static int preprocess(const char *file, int write_fd, int rlevel)
 
                        continue;
                }
-
-               write(write_fd, bp, (unsigned) cur);
+\r
+               if(write(write_fd, bp, (unsigned) cur) != (int) cur) {\r
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");\r
+               }\r
+\r
        }
 
        close(read_fd);