mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
More strlen_zero checks (bug #1549)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2887 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
13
asterisk.c
13
asterisk.c
@@ -31,6 +31,7 @@
|
|||||||
#include <asterisk/rtp.h>
|
#include <asterisk/rtp.h>
|
||||||
#include <asterisk/app.h>
|
#include <asterisk/app.h>
|
||||||
#include <asterisk/lock.h>
|
#include <asterisk/lock.h>
|
||||||
|
#include <asterisk/utils.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -546,7 +547,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
|
|||||||
if (option_console || option_remote) {
|
if (option_console || option_remote) {
|
||||||
if (getenv("HOME"))
|
if (getenv("HOME"))
|
||||||
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
|
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
|
||||||
if (strlen(filename))
|
if (!ast_strlen_zero(filename))
|
||||||
ast_el_write_history(filename);
|
ast_el_write_history(filename);
|
||||||
if (el != NULL)
|
if (el != NULL)
|
||||||
el_end(el);
|
el_end(el);
|
||||||
@@ -640,7 +641,7 @@ static void consolehandler(char *s)
|
|||||||
printf(term_end());
|
printf(term_end());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
/* Called when readline data is available */
|
/* Called when readline data is available */
|
||||||
if (s && strlen(s))
|
if (s && !ast_strlen_zero(s))
|
||||||
ast_el_add_history(s);
|
ast_el_add_history(s);
|
||||||
/* Give the console access to the shell */
|
/* Give the console access to the shell */
|
||||||
if (s) {
|
if (s) {
|
||||||
@@ -660,7 +661,7 @@ static int remoteconsolehandler(char *s)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
/* Called when readline data is available */
|
/* Called when readline data is available */
|
||||||
if (s && strlen(s))
|
if (s && !ast_strlen_zero(s))
|
||||||
ast_el_add_history(s);
|
ast_el_add_history(s);
|
||||||
/* Give the console access to the shell */
|
/* Give the console access to the shell */
|
||||||
if (s) {
|
if (s) {
|
||||||
@@ -1334,7 +1335,7 @@ static void ast_remotecontrol(char * data)
|
|||||||
|
|
||||||
el_set(el, EL_GETCFN, ast_el_read_char);
|
el_set(el, EL_GETCFN, ast_el_read_char);
|
||||||
|
|
||||||
if (strlen(filename))
|
if (!ast_strlen_zero(filename))
|
||||||
ast_el_read_history(filename);
|
ast_el_read_history(filename);
|
||||||
|
|
||||||
ast_cli_register(&quit);
|
ast_cli_register(&quit);
|
||||||
@@ -1350,7 +1351,7 @@ static void ast_remotecontrol(char * data)
|
|||||||
for(;;) {
|
for(;;) {
|
||||||
ebuf = (char *)el_gets(el, &num);
|
ebuf = (char *)el_gets(el, &num);
|
||||||
|
|
||||||
if (ebuf && strlen(ebuf)) {
|
if (ebuf && !ast_strlen_zero(ebuf)) {
|
||||||
if (ebuf[strlen(ebuf)-1] == '\n')
|
if (ebuf[strlen(ebuf)-1] == '\n')
|
||||||
ebuf[strlen(ebuf)-1] = '\0';
|
ebuf[strlen(ebuf)-1] = '\0';
|
||||||
if (!remoteconsolehandler(ebuf)) {
|
if (!remoteconsolehandler(ebuf)) {
|
||||||
@@ -1555,7 +1556,7 @@ int main(int argc, char *argv[])
|
|||||||
if (el_hist == NULL || el == NULL)
|
if (el_hist == NULL || el == NULL)
|
||||||
ast_el_initialize();
|
ast_el_initialize();
|
||||||
|
|
||||||
if (strlen(filename))
|
if (!ast_strlen_zero(filename))
|
||||||
ast_el_read_history(filename);
|
ast_el_read_history(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
config.c
7
config.c
@@ -20,6 +20,7 @@
|
|||||||
#include <asterisk/config.h>
|
#include <asterisk/config.h>
|
||||||
#include <asterisk/options.h>
|
#include <asterisk/options.h>
|
||||||
#include <asterisk/logger.h>
|
#include <asterisk/logger.h>
|
||||||
|
#include <asterisk/utils.h>
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
#include "astconf.h"
|
#include "astconf.h"
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ static char *strip(char *buf)
|
|||||||
{
|
{
|
||||||
char *start;
|
char *start;
|
||||||
/* Strip off trailing whitespace, returns, etc */
|
/* Strip off trailing whitespace, returns, etc */
|
||||||
while(strlen(buf) && (buf[strlen(buf)-1]<33))
|
while(!ast_strlen_zero(buf) && (buf[strlen(buf)-1]<33))
|
||||||
buf[strlen(buf)-1] = '\0';
|
buf[strlen(buf)-1] = '\0';
|
||||||
start = buf;
|
start = buf;
|
||||||
/* Strip off leading whitespace, returns, etc */
|
/* Strip off leading whitespace, returns, etc */
|
||||||
@@ -469,7 +470,7 @@ static int cfg_process(struct ast_config *tmp, struct ast_category **_tmpc, stru
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
cur = strip(buf);
|
cur = strip(buf);
|
||||||
if (strlen(cur)) {
|
if (!ast_strlen_zero(cur)) {
|
||||||
/* Actually parse the entry */
|
/* Actually parse the entry */
|
||||||
if (cur[0] == '[') {
|
if (cur[0] == '[') {
|
||||||
/* A category header */
|
/* A category header */
|
||||||
@@ -525,7 +526,7 @@ static int cfg_process(struct ast_config *tmp, struct ast_category **_tmpc, stru
|
|||||||
while((*c == '<') || (*c == '>') || (*c == '\"')) c++;
|
while((*c == '<') || (*c == '>') || (*c == '\"')) c++;
|
||||||
/* Get rid of leading mess */
|
/* Get rid of leading mess */
|
||||||
cur = c;
|
cur = c;
|
||||||
while(strlen(cur)) {
|
while(!ast_strlen_zero(cur)) {
|
||||||
c = cur + strlen(cur) - 1;
|
c = cur + strlen(cur) - 1;
|
||||||
if ((*c == '>') || (*c == '<') || (*c == '\"'))
|
if ((*c == '>') || (*c == '<') || (*c == '\"'))
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
|
3
enum.c
3
enum.c
@@ -32,6 +32,7 @@
|
|||||||
#include <asterisk/dns.h>
|
#include <asterisk/dns.h>
|
||||||
#include <asterisk/channel.h>
|
#include <asterisk/channel.h>
|
||||||
#include <asterisk/config.h>
|
#include <asterisk/config.h>
|
||||||
|
#include <asterisk/utils.h>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#undef T_NAPTR
|
#undef T_NAPTR
|
||||||
@@ -237,7 +238,7 @@ static int enum_callback(void *context, u_char *answer, int len, u_char *fullans
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(c->dst))
|
if (!ast_strlen_zero(c->dst))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
7
say.c
7
say.c
@@ -23,6 +23,7 @@
|
|||||||
#include <asterisk/say.h>
|
#include <asterisk/say.h>
|
||||||
#include <asterisk/lock.h>
|
#include <asterisk/lock.h>
|
||||||
#include <asterisk/localtime.h>
|
#include <asterisk/localtime.h>
|
||||||
|
#include <asterisk/utils.h>
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ int ast_say_digit_str(struct ast_channel *chan, char *fn2, char *ints, char *lan
|
|||||||
snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
|
snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(strlen(fn)){ /* if length == 0, then skip this digit as it is invalid */
|
if(!ast_strlen_zero(fn)){ /* if length == 0, then skip this digit as it is invalid */
|
||||||
res = ast_streamfile(chan, fn, lang);
|
res = ast_streamfile(chan, fn, lang);
|
||||||
if (!res)
|
if (!res)
|
||||||
res = ast_waitstream(chan, ints);
|
res = ast_waitstream(chan, ints);
|
||||||
@@ -121,7 +122,7 @@ int ast_say_character_str(struct ast_channel *chan, char *fn2, char *ints, char
|
|||||||
if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */
|
if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */
|
||||||
snprintf(fn, sizeof(fn), "letters/%c", ltr);
|
snprintf(fn, sizeof(fn), "letters/%c", ltr);
|
||||||
}
|
}
|
||||||
if(strlen(fn)){ /* if length == 0, then skip this digit as it is invalid */
|
if(!ast_strlen_zero(fn)) { /* if length == 0, then skip this digit as it is invalid */
|
||||||
res = ast_streamfile(chan, fn, lang);
|
res = ast_streamfile(chan, fn, lang);
|
||||||
if (!res)
|
if (!res)
|
||||||
res = ast_waitstream(chan, ints);
|
res = ast_waitstream(chan, ints);
|
||||||
@@ -192,7 +193,7 @@ int ast_say_phonetic_str(struct ast_channel *chan, char *fn2, char *ints, char *
|
|||||||
case ('%'):
|
case ('%'):
|
||||||
play=0;
|
play=0;
|
||||||
/* check if we have 2 chars after the % */
|
/* check if we have 2 chars after the % */
|
||||||
if (strlen(fn2)>num+2)
|
if (strlen(fn2) > num+2)
|
||||||
{
|
{
|
||||||
hex[0]=fn2[num+1];
|
hex[0]=fn2[num+1];
|
||||||
hex[1]=fn2[num+2];
|
hex[1]=fn2[num+2];
|
||||||
|
3
srv.c
3
srv.c
@@ -27,6 +27,7 @@
|
|||||||
#include <asterisk/srv.h>
|
#include <asterisk/srv.h>
|
||||||
#include <asterisk/dns.h>
|
#include <asterisk/dns.h>
|
||||||
#include <asterisk/options.h>
|
#include <asterisk/options.h>
|
||||||
|
#include <asterisk/utils.h>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#undef T_SRV
|
#undef T_SRV
|
||||||
@@ -84,7 +85,7 @@ static int srv_callback(void *context, u_char *answer, int len, u_char *fullansw
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(c->host))
|
if (!ast_strlen_zero(c->host))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user