char *val;
/* Read environment */
for(;;) {
- fgets(buf, sizeof(buf), stdin);
+ if (!fgets(buf, sizeof(buf), stdin)) {
+ return -1;
+ }
if (feof(stdin))
return -1;
buf[strlen(buf) - 1] = '\0';
return NULL;
}
if (FD_ISSET(STDIN_FILENO, &fds)) {
- fgets(astresp, sizeof(astresp), stdin);
+ if (!fgets(astresp, sizeof(astresp), stdin)) {
+ return NULL;
+ }
if (feof(stdin)) {
fprintf(stderr, "Got hungup on apparently\n");
return NULL;
}
if (FD_ISSET(AUDIO_FILENO, &fds)) {
res = read(AUDIO_FILENO, audiobuf, sizeof(audiobuf));
- if (res > 0) {
- if (sphinx_sock > -1)
- write(sphinx_sock, audiobuf, res);
+ if ((res > 0) && (sphinx_sock > -1)) {
+ if (write(sphinx_sock, audiobuf, res) < 0) {
+ fprintf(stderr, "write() failed: %s\n", strerror(errno));
+ }
}
}
if ((sphinx_sock > -1) && FD_ISSET(sphinx_sock, &fds)) {
char *val;
/* Read environment */
for(;;) {
- fgets(buf, sizeof(buf), stdin);
+ if (!fgets(buf, sizeof(buf), stdin)) {
+ return -1;
+ }
if (feof(stdin))
return -1;
buf[strlen(buf) - 1] = '\0';
return NULL;
}
if (FD_ISSET(STDIN_FILENO, &fds)) {
- fgets(astresp, sizeof(astresp), stdin);
+ if (!fgets(astresp, sizeof(astresp), stdin)) {
+ return NULL;
+ }
if (feof(stdin)) {
fprintf(stderr, "Got hungup on apparently\n");
return NULL;
/* Create "main" as first subroutine */
getsubbyname(scr, "main", NULL, 0);
while (!feof(f)) {
- fgets(buf, sizeof(buf), f);
+ if (!fgets(buf, sizeof(buf), f)) {
+ continue;
+ }
if (!feof(f)) {
lineno++;
/* Trim off trailing return */
if (feof(f))
break;
- fgets(buf, sizeof(buf), f);
+ if (!fgets(buf, sizeof(buf), f)) {
+ continue;
+ }
if (ast_strlen_zero(buf))
continue;
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <ctype.h>
+#include <errno.h>
#include "asterisk/paths.h" /* use ast_config_AST_MONITOR_DIR */
#include "asterisk/file.h"
return -1;
}
- if (csth->fd)
- write(csth->fd, f->data.ptr, f->datalen);
+ if (csth->fd) {
+ if (write(csth->fd, f->data.ptr, f->datalen) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
+ }
ast_frfree(f);
gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ',');
if (gosub_argstart) {
*gosub_argstart = 0;
- asprintf(&gosub_args, "%s,s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], gosub_argstart + 1);
+ if (asprintf(&gosub_args, "%s,s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], gosub_argstart + 1) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ gosub_args = NULL;
+ }
*gosub_argstart = ',';
} else {
- asprintf(&gosub_args, "%s,s,1", opt_args[OPT_ARG_CALLEE_GOSUB]);
+ if (asprintf(&gosub_args, "%s,s,1", opt_args[OPT_ARG_CALLEE_GOSUB]) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ gosub_args = NULL;
+ }
}
if (gosub_args) {
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>
+#include <errno.h>
#include "asterisk/file.h"
#include "asterisk/channel.h"
*(waveform + x) = c;
}
#endif
- write(fd, waveform, length);
+
+ if (write(fd, waveform, length) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
+
close(fd);
exit(0);
}
writecache = 1;
strln = strlen(args.text);
ast_debug(1, "line length : %d\n", strln);
- write(fdesc, &strln, sizeof(strln));
- write(fdesc, args.text, strln);
+ if (write(fdesc,&strln,sizeof(int)) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
+ if (write(fdesc,data,strln) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
seekpos = lseek(fdesc, 0, SEEK_CUR);
ast_debug(1, "Seek position : %d\n", seekpos);
}
} else {
- read(fdesc, &strln, sizeof(strln));
+ if (read(fdesc,&strln,sizeof(int)) != sizeof(int)) {
+ ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
+ }
ast_debug(1, "Cache file exists, strln=%d, strlen=%d\n", strln, (int)strlen(args.text));
if (strlen(args.text) == strln) {
ast_debug(1, "Size OK\n");
- read(fdesc, &bigstring, strln);
+ if (read(fdesc,&bigstring,strln) != strln) {
+ ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
+ }
bigstring[strln] = 0;
if (strcmp(bigstring, args.text) == 0) {
readcache = 1;
if (writecache == 1) {
ast_debug(1, "Writing result to cache...\n");
while ((strln = read(fd, buffer, 16384)) != 0) {
- write(fdesc, buffer, strln);
+ if (write(fdesc,buffer,strln) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
}
close(fd);
close(fdesc);
gosub_argstart = strchr(gosubexec, ',');
if (gosub_argstart) {
*gosub_argstart = 0;
- asprintf(&gosub_args, "%s,s,1(%s)", gosubexec, gosub_argstart + 1);
+ if (asprintf(&gosub_args, "%s,s,1(%s)", gosubexec, gosub_argstart + 1) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ gosub_args = NULL;
+ }
*gosub_argstart = '|';
} else {
- asprintf(&gosub_args, "%s,s,1", gosubexec);
+ if (asprintf(&gosub_args, "%s,s,1", gosubexec) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ gosub_args = NULL;
+ }
}
if (gosub_args) {
res = pbx_exec(qe->chan, application, gosub_args);
}
*p++ = '\n';
*p = 0;
- write(o, line, strlen(line));
+ if (write(o, line, strlen(line)) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
close(o);
}
*h->oa = *h->da = h->udl = 0;
* call a Gosub for the CALLEE channel in Dial or Queue.
*/
if (argc == 5) {
- asprintf(&gosub_args, "%s,%s,%d(%s)", argv[1], argv[2], priority + 1, argv[4]);
+ if (asprintf(&gosub_args, "%s,%s,%d(%s)", argv[1], argv[2], priority + 1, argv[4]) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ gosub_args = NULL;
+ }
} else {
- asprintf(&gosub_args, "%s,%s,%d", argv[1], argv[2], priority + 1);
+ if (asprintf(&gosub_args, "%s,%s,%d", argv[1], argv[2], priority + 1) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ gosub_args = NULL;
+ }
}
if (gosub_args) {
} else if (pid) {
/* parent */
close(fds[1]);
- read(fds[0], buf, len);
+ if (read(fds[0], buf, len) < 0) {
+ ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
+ }
close(fds[0]);
} else {
/* child */
f = fopen(fn2, "r");
if (f) {
while (!feof(f)) {
- fgets((char *)buf, sizeof(buf), f);
+ if (!fgets((char *)buf, sizeof(buf), f)) {
+ continue;
+ }
if (!feof(f)) {
char *stringp=NULL;
stringp = (char *)buf;
ast_mutex_lock(&pridebugfdlock);
- if (pridebugfd >= 0)
- write(pridebugfd, s, strlen(s));
+ if (pridebugfd >= 0) {
+ if (write(pridebugfd, s, strlen(s)) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
+ }
ast_mutex_unlock(&pridebugfdlock);
}
ast_mutex_lock(&pridebugfdlock);
- if (pridebugfd >= 0)
- write(pridebugfd, s, strlen(s));
+ if (pridebugfd >= 0) {
+ if (write(pridebugfd, s, strlen(s)) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
+ }
ast_mutex_unlock(&pridebugfdlock);
}
static int update_common_options(struct ast_variable *v, struct call_options *options)
{
- int tmp;
+ int tmp = 0;
char *val, *opt;
if (!strcasecmp(v->name, "allow")) {
}
/* Wake up waiters */
for (x = 0; x < ARRAY_LEN(dp->waiters); x++) {
- if (dp->waiters[x] > -1)
- write(dp->waiters[x], "asdf", 4);
+ if (dp->waiters[x] > -1) {
+ if (write(dp->waiters[x], "asdf", 4) < 0) {
+ }
+ }
}
}
AST_LIST_TRAVERSE_SAFE_END;
systems without leaving it unavailable once the server comes back online */
dp->expiry.tv_sec = dp->orig.tv_sec + 60;
for (x = 0; x < ARRAY_LEN(dp->waiters); x++) {
- if (dp->waiters[x] > -1)
- write(dp->waiters[x], "asdf", 4);
+ if (dp->waiters[x] > -1) {
+ if (write(dp->waiters[x], "asdf", 4) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
+ }
}
}
}
if (o->mixer_cmd) {
char *cmd;
- asprintf(&cmd, "mixer %s", o->mixer_cmd);
- ast_log(LOG_WARNING, "running [%s]\n", cmd);
- system(cmd);
- ast_free(cmd);
+ if (asprintf(&cmd, "mixer %s", o->mixer_cmd) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ } else {
+ ast_log(LOG_WARNING, "running [%s]\n", cmd);
+ if (system(cmd) < 0) {
+ ast_log(LOG_WARNING, "system() failed: %s\n", strerror(errno));
+ }
+ ast_free(cmd);
+ }
}
/* if the config file requested to start the GUI, do it */
if (!ast_strlen_zero(callback)) { /* build string from peer info */
char *reg_string;
- asprintf(®_string, "%s:%s@%s/%s", peer->username, peer->secret, peer->tohost, callback);
- if (reg_string) {
+ if (asprintf(®_string, "%s:%s@%s/%s", peer->username, peer->secret, peer->tohost, callback) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ } else if (reg_string) {
sip_register(reg_string, 0); /* XXX TODO: count in registry_count */
ast_free(reg_string);
}
int i;
fseeko(fs->f, 0, SEEK_END);
for (i=0; i< (offset - max) / GSM_FRAME_SIZE; i++) {
- fwrite(gsm_silence, 1, GSM_FRAME_SIZE, fs->f);
+ if (!fwrite(gsm_silence, 1, GSM_FRAME_SIZE, fs->f)) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
}
}
return fseeko(fs->f, offset, SEEK_SET);
while (!tmp->eos) {
if (ogg_stream_flush(&tmp->os, &tmp->og) == 0)
break;
- fwrite(tmp->og.header, 1, tmp->og.header_len, s->f);
- fwrite(tmp->og.body, 1, tmp->og.body_len, s->f);
+ if (!fwrite(tmp->og.header, 1, tmp->og.header_len, s->f)) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
+ if (!fwrite(tmp->og.body, 1, tmp->og.body_len, s->f)) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
if (ogg_page_eos(&tmp->og))
tmp->eos = 1;
}
if (ogg_stream_pageout(&s->os, &s->og) == 0) {
break;
}
- fwrite(s->og.header, 1, s->og.header_len, f);
- fwrite(s->og.body, 1, s->og.body_len, f);
+ if (!fwrite(s->og.header, 1, s->og.header_len, f)) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
+ if (!fwrite(s->og.body, 1, s->og.body_len, f)) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
if (ogg_page_eos(&s->og)) {
s->eos = 1;
}
}
/* Pad to even length */
- if (fs->bytes & 0x1)
- fwrite(&zero, 1, 1, s->f);
+ if (fs->bytes & 0x1) {
+ if (!fwrite(&zero, 1, 1, s->f)) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
+ }
}
static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
int i;
fseek(fs->f, 0, SEEK_END);
for (i=0; i< (offset - max) / MSGSM_FRAME_SIZE; i++) {
- fwrite(msgsm_silence, 1, MSGSM_FRAME_SIZE, fs->f);
+ if (!fwrite(msgsm_silence, 1, MSGSM_FRAME_SIZE, fs->f)) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
}
}
s->secondhalf = 0;
}
if ((tmp = ast_variable_retrieve(cfg, catg, "prefix")) && !ast_strlen_zero(tmp)) {
- asprintf((char **)&((*query)->acf->name), "%s_%s", tmp, catg);
+ if (asprintf((char **)&((*query)->acf->name), "%s_%s", tmp, catg) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ }
} else {
- asprintf((char **)&((*query)->acf->name), "ODBC_%s", catg);
+ if (asprintf((char **)&((*query)->acf->name), "ODBC_%s", catg) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ }
}
if (!((*query)->acf->name)) {
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
#define UINT32_MAX (4294967295U)
#endif
+#endif /* ! C99 */
+
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
#else /* ! __cplusplus */
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
#define YY_USE_CONST
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
-int ast_yylex_init (yyscan_t* scanner);
-
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
+typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
static int curlycount = 0;
static char *expr2_token_subst(const char *mess);
-#line 2410 "ast_expr2f.c"
+#line 2403 "ast_expr2f.c"
#define INITIAL 0
#define var 1
# define yylloc yyg->yylloc_r
+int ast_yylex_init (yyscan_t* scanner);
+
+int ast_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-#line 127 "ast_expr2.fl"
+#line 125 "ast_expr2.fl"
-#line 2636 "ast_expr2f.c"
+#line 2633 "ast_expr2f.c"
yylval = yylval_param;
case 1:
YY_RULE_SETUP
-#line 129 "ast_expr2.fl"
+#line 127 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_OR;}
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 130 "ast_expr2.fl"
+#line 128 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_AND;}
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 131 "ast_expr2.fl"
+#line 129 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_EQ;}
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 132 "ast_expr2.fl"
+#line 130 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_OR;}
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 133 "ast_expr2.fl"
+#line 131 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_AND;}
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 134 "ast_expr2.fl"
+#line 132 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_EQ;}
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 135 "ast_expr2.fl"
+#line 133 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_EQTILDE;}
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 136 "ast_expr2.fl"
+#line 134 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_TILDETILDE;}
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 137 "ast_expr2.fl"
+#line 135 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_GT;}
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 138 "ast_expr2.fl"
+#line 136 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_LT;}
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 139 "ast_expr2.fl"
+#line 137 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_GE;}
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 140 "ast_expr2.fl"
+#line 138 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_LE;}
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 141 "ast_expr2.fl"
+#line 139 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_NE;}
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 142 "ast_expr2.fl"
+#line 140 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_PLUS;}
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 143 "ast_expr2.fl"
+#line 141 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_COMMA;}
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 144 "ast_expr2.fl"
+#line 142 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_MINUS;}
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 145 "ast_expr2.fl"
+#line 143 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_MULT;}
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 146 "ast_expr2.fl"
+#line 144 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_DIV;}
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 147 "ast_expr2.fl"
+#line 145 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_MOD;}
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 148 "ast_expr2.fl"
+#line 146 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_COND;}
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 149 "ast_expr2.fl"
+#line 147 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_COMPL;}
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 150 "ast_expr2.fl"
+#line 148 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_COLON;}
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 151 "ast_expr2.fl"
+#line 149 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;}
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 152 "ast_expr2.fl"
+#line 150 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_LP;}
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 153 "ast_expr2.fl"
+#line 151 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_RP;}
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 154 "ast_expr2.fl"
+#line 152 "ast_expr2.fl"
{
/* gather the contents of ${} expressions, with trailing stuff,
* into a single TOKEN.
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 164 "ast_expr2.fl"
+#line 162 "ast_expr2.fl"
{}
YY_BREAK
case 28:
/* rule 28 can match eol */
YY_RULE_SETUP
-#line 165 "ast_expr2.fl"
+#line 163 "ast_expr2.fl"
{SET_COLUMNS; SET_STRING; return TOKEN;}
YY_BREAK
case 29:
/* rule 29 can match eol */
YY_RULE_SETUP
-#line 167 "ast_expr2.fl"
+#line 165 "ast_expr2.fl"
{/* what to do with eol */}
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 168 "ast_expr2.fl"
+#line 166 "ast_expr2.fl"
{
SET_COLUMNS;
/* the original behavior of the expression parser was
case 31:
/* rule 31 can match eol */
YY_RULE_SETUP
-#line 177 "ast_expr2.fl"
+#line 175 "ast_expr2.fl"
{
SET_COLUMNS;
SET_STRING;
case 32:
/* rule 32 can match eol */
YY_RULE_SETUP
-#line 184 "ast_expr2.fl"
+#line 182 "ast_expr2.fl"
{
curlycount--;
if (curlycount < 0) {
case 33:
/* rule 33 can match eol */
YY_RULE_SETUP
-#line 194 "ast_expr2.fl"
+#line 192 "ast_expr2.fl"
{
curlycount++;
yymore();
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 200 "ast_expr2.fl"
+#line 198 "ast_expr2.fl"
{
BEGIN(0);
SET_COLUMNS;
case 35:
/* rule 35 can match eol */
YY_RULE_SETUP
-#line 207 "ast_expr2.fl"
+#line 205 "ast_expr2.fl"
{
char c = yytext[yyleng-1];
BEGIN(0);
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 216 "ast_expr2.fl"
+#line 214 "ast_expr2.fl"
{
curlycount = 0;
BEGIN(var);
}
YY_BREAK
case YY_STATE_EOF(trail):
-#line 222 "ast_expr2.fl"
+#line 220 "ast_expr2.fl"
{
BEGIN(0);
SET_COLUMNS;
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 230 "ast_expr2.fl"
+#line 228 "ast_expr2.fl"
ECHO;
YY_BREAK
-#line 2964 "ast_expr2f.c"
+#line 2961 "ast_expr2f.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(var):
yyterminate();
else
ret_val = EOB_ACT_CONTINUE_SCAN;
+ if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ast_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
yyg->yy_n_chars += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
-
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" );
+
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc;
(yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
return yy_init_globals ( *ptr_yy_globals );
}
+/* ast_yylex_init_extra has the same functionality as ast_yylex_init, but follows the
+ * convention of taking the scanner as the last argument. Note however, that
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
+ * is the reason, too, why this function also must handle its own declaration).
+ * The user defined value in the first argument will be available to ast_yyalloc in
+ * the yyextra field.
+ */
+
+int ast_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
+
+{
+ struct yyguts_t dummy_yyguts;
+
+ ast_yyset_extra (yy_user_defined, &dummy_yyguts);
+
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) ast_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in
+ yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ ast_yyset_extra (yy_user_defined, *ptr_yy_globals);
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
#define YYTABLES_NAME "yytables"
-#line 230 "ast_expr2.fl"
+#line 228 "ast_expr2.fl"
if (restartnow)
execvp(_argv[0], _argv);
sig_flags.need_reload = 1;
- if (sig_alert_pipe[1] != -1)
- write(sig_alert_pipe[1], &a, sizeof(a));
+ if (sig_alert_pipe[1] != -1) {
+ if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {
+ fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));
+ }
+ }
signal(num, hup_handler);
}
{
int a = 0;
sig_flags.need_quit = 1;
- if (sig_alert_pipe[1] != -1)
- write(sig_alert_pipe[1], &a, sizeof(a));
+ if (sig_alert_pipe[1] != -1) {
+ if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {
+ fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));
+ }
+ }
/* There is no need to restore the signal handler here, since the app
* is going to exit */
}
return NULL;
}
- ast_cli(a->fd, warranty_lines);
+ ast_cli(a->fd, "%s", warranty_lines);
return CLI_SUCCESS;
}
return NULL;
}
- ast_cli(a->fd, license_lines);
+ ast_cli(a->fd, "%s", license_lines);
return CLI_SUCCESS;
}
}
/* Write over the CLI prompt */
- if (!ast_opt_exec && !lastpos)
- write(STDOUT_FILENO, "\r", 1);
- write(STDOUT_FILENO, buf, res);
+ if (!ast_opt_exec && !lastpos) {
+ if (write(STDOUT_FILENO, "\r", 1) < 0) {
+ }
+ }
+ if (write(STDOUT_FILENO, buf, res) < 0) {
+ }
if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (buf[res-2] == '\n'))) {
*cp = CC_REFRESH;
return(1);
return ret;
}
-static void ast_remotecontrol(char * data)
+static void ast_remotecontrol(char *data)
{
char buf[80];
int res;
char *ebuf;
int num = 0;
- read(ast_consock, buf, sizeof(buf));
+ if (read(ast_consock, buf, sizeof(buf)) < 0) {
+ ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno));
+ return;
+ }
if (data) {
char prefix[] = "cli quit after ";
char *tmp = alloca(strlen(data) + strlen(prefix) + 1);
sprintf(tmp, "%s%s", prefix, data);
- write(ast_consock, tmp, strlen(tmp) + 1);
+ if (write(ast_consock, tmp, strlen(tmp) + 1) < 0) {
+ ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno));
+ }
}
stringp = buf;
hostname = strsep(&stringp, "/");
/* Skip verbose lines */
if (*curline != 127) {
not_written = 0;
- write(STDOUT_FILENO, curline, nextline - curline);
+ if (write(STDOUT_FILENO, curline, nextline - curline) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
}
curline = nextline;
} while (!ast_strlen_zero(curline));
sig_flags.need_quit = 0;
quit_handler(0, 0, 1, 0);
}
- read(sig_alert_pipe[0], &a, sizeof(a));
+ if (read(sig_alert_pipe[0], &a, sizeof(a)) != sizeof(a)) {
+ }
}
return NULL;
#if HAVE_WORKING_FORK
if (ast_opt_always_fork || !ast_opt_no_fork) {
#ifndef HAVE_SBIN_LAUNCHD
- daemon(1, 0);
+ if (daemon(1, 0) < 0) {
+ ast_log(LOG_ERROR, "daemon() failed: %s\n", strerror(errno));
+ }
ast_mainpid = getpid();
/* Blindly re-write pid file since we are forking */
unlink(ast_config_AST_PID);
break;
case AST_FRAME_VOICE:
/* Write audio if appropriate */
- if (audiofd > -1)
- write(audiofd, f->data.ptr, f->datalen);
+ if (audiofd > -1) {
+ if (write(audiofd, f->data.ptr, f->datalen) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
+ }
default:
/* Ignore */
break;
goto done;
}
}
- read(chan->alertpipe[0], &blah, sizeof(blah));
+ if (read(chan->alertpipe[0], &blah, sizeof(blah)) < 0) {
+ ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
+ }
}
if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD) {
AST_LIST_INSERT_TAIL(&original->readq, current, frame_list);
if (original->alertpipe[1] > -1) {
int poke = 0;
- write(original->alertpipe[1], &poke, sizeof(poke));
+
+ if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
}
}
}
#define OVMSG "HASH: Out of overflow pages. Increase page size\n"
if (offset > SPLITMASK) {
if (++splitnum >= NCACHED) {
- (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1);
+ if (write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1) < 0) {
+ }
return (0);
}
hashp->OVFL_POINT = splitnum;
if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) {
free_page++;
if (free_page >= NCACHED) {
- (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1);
+ if (write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1) < 0) {
+ }
return (0);
}
/*
offset++;
if (offset > SPLITMASK) {
if (++splitnum >= NCACHED) {
- (void)write(STDERR_FILENO, OVMSG,
- sizeof(OVMSG) - 1);
+ if (write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1) < 0) {
+ }
return (0);
}
hashp->OVFL_POINT = splitnum;
if (!strcmp(ext, "wav49"))
ext = "WAV";
- if (filename[0] == '/')
- asprintf(&fn, "%s.%s", filename, ext);
- else
- asprintf(&fn, "%s/sounds/%s.%s",
- ast_config_AST_DATA_DIR, filename, ext);
+ if (filename[0] == '/') {
+ if (asprintf(&fn, "%s.%s", filename, ext) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ fn = NULL;
+ }
+ } else {
+ if (asprintf(&fn, "%s/sounds/%s.%s",
+ ast_config_AST_DATA_DIR, filename, ext) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ fn = NULL;
+ }
+ }
return fn;
}
break;
case AST_FRAME_VOICE:
/* Write audio if appropriate */
- if (audiofd > -1)
- write(audiofd, fr->data.ptr, fr->datalen);
+ if (audiofd > -1) {
+ if (write(audiofd, fr->data.ptr, fr->datalen) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
+ }
default:
/* Ignore all others */
break;
ast_get_version(), buf, (int) st.st_size, mtype);
while ((len = read(fd, buf, sizeof(buf))) > 0) {
- fwrite(buf, 1, len, ser->f);
+ if (fwrite(buf, 1, len, ser->f) != len) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
}
close(fd);
if (tmp) {
fprintf(ser->f, "Content-length: %d\r\n", contentlength);
/* first write the header, then the body */
- fwrite(out->str, 1, (tmp + 4 - out->str), ser->f);
- fwrite(tmp + 4, 1, contentlength, ser->f);
+ if (fwrite(out->str, 1, (tmp + 4 - out->str), ser->f) != tmp + 4 - out->str) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
+ if (fwrite(tmp + 4, 1, contentlength, ser->f) != contentlength ) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
}
}
ast_free(out);
char buf[512];
pbx_builtin_setvar_helper(c, "filename", filename);
pbx_substitute_variables_helper(c, exec_after_rotate, buf, sizeof(buf));
- system(buf);
+ if (system(buf) < 0) {
+ ast_log(LOG_WARNING, "system() failed for '%s': %s\n", buf, strerror(errno));
+ }
ast_channel_free(c);
}
return res;
final_buf = ast_calloc(1, l + 1);
if (buf) {
lseek(fd, 0, SEEK_SET);
- read(fd, buf, l);
+ if (read(fd, buf, l) < 0) {
+ ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
+ }
buf[l] = '\0';
if (final_buf) {
term_strip(final_buf, buf, l);
a->start_routine = start_routine;
a->data = data;
start_routine = dummy_start;
- asprintf(&a->name, "%-20s started at [%5d] %s %s()",
- start_fn, line, file, caller);
+ if (asprintf(&a->name, "%-20s started at [%5d] %s %s()",
+ start_fn, line, file, caller) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ a->name = NULL;
+ }
data = a;
}
#endif /* !LOW_MEMORY */
if (++which > a->n) {
/* If there is an extension then return exten@context. */
if (ast_get_extension_matchcid(e) && (!strchr(a->word, '@') || strchr(a->word, '/'))) {
- asprintf(&ret, "%s/%s@%s", ast_get_extension_name(e), ast_get_extension_cidmatch(e), ast_get_context_name(c));
+ if (asprintf(&ret, "%s/%s@%s", ast_get_extension_name(e), ast_get_extension_cidmatch(e), ast_get_context_name(c)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ ret = NULL;
+ }
break;
} else if (!ast_get_extension_matchcid(e) && !strchr(a->word, '/')) {
- asprintf(&ret, "%s@%s", ast_get_extension_name(e), ast_get_context_name(c));
+ if (asprintf(&ret, "%s@%s", ast_get_extension_name(e), ast_get_context_name(c)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ ret = NULL;
+ }
break;
}
}
if (AST_LIST_EMPTY(&trans->parent->trans)) {
/* Wake up sleeper */
if (trans->parent->pfds[1] > -1) {
- write(trans->parent->pfds[1], "killa!", 6);
+ if (write(trans->parent->pfds[1], "killa!", 6) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
}
}
}
dr.expiration = dundi_cache_time;
dr.hmd = &hmd;
dr.pfds[0] = dr.pfds[1] = -1;
- pipe(dr.pfds);
+ if (pipe(dr.pfds) < 0) {
+ ast_log(LOG_WARNING, "pipe() failed: %s\n", strerror(errno));
+ return -1;
+ }
build_transactions(&dr, ttl, 0, &foundcache, &skipped, 0, 1, 1, NULL, avoids, NULL);
optimize_transactions(&dr, 0);
foundanswers = 0;
return NULL;
}
- fread(data, sizeof(char), *size, f);
+ if (fread(data, sizeof(char), *size, f) != *size) {
+ ast_log(LOG_WARNING, "fread() failed: %s\n", strerror(errno));
+ }
fclose(f);
if (luaL_loadbuffer(L, data, *size, "extensions.lua")
my_file = strdup(filename);
stat(filename, &stats);
buffer = (char*)malloc(stats.st_size+2);
- fread(buffer, 1, stats.st_size, fin);
+ if (fread(buffer, 1, stats.st_size, fin) != stats.st_size) {
+ ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
+ }
buffer[stats.st_size]=0;
fclose(fin);
struct stat stats;
stat(fnamebuf2, &stats);
buffer = (char*)malloc(stats.st_size+1);
- fread(buffer, 1, stats.st_size, in1);
+ if (fread(buffer, 1, stats.st_size, in1) != stats.st_size) {
+ ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
+ }
buffer[stats.st_size] = 0;
ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size);
fclose(in1);
237, 238, 239, 242, 242, 248, 248, 255, 256, 257,
258, 261, 262, 263, 266, 267, 268, 269, 270, 271,
272, 273, 274, 277, 282, 286, 294, 299, 304, 313,
- 314, 315, 321, 326, 330, 338, 338, 342, 345, 348,
- 359, 360, 367, 368, 372, 376, 382, 383, 388, 396,
- 397, 401, 407, 416, 419, 420, 421, 424, 427, 430,
- 431, 432, 430, 438, 442, 443, 444, 445, 448, 448,
- 481, 482, 483, 484, 488, 491, 492, 495, 496, 499,
- 502, 506, 510, 514, 520, 521, 525, 528, 534, 534,
- 539, 547, 547, 558, 565, 568, 569, 572, 573, 576,
- 579, 580, 583, 587, 591, 597, 598, 601, 602, 603,
- 609, 614, 619, 620, 621, 623, 626, 627, 634, 635,
- 636, 639, 642
+ 314, 315, 321, 331, 335, 343, 343, 347, 350, 353,
+ 364, 365, 377, 378, 387, 396, 407, 408, 418, 431,
+ 432, 441, 452, 461, 464, 465, 466, 469, 472, 475,
+ 476, 477, 475, 483, 487, 488, 489, 490, 493, 493,
+ 526, 527, 528, 529, 533, 536, 537, 540, 541, 544,
+ 547, 551, 555, 559, 565, 566, 570, 573, 579, 579,
+ 584, 592, 592, 603, 610, 613, 614, 617, 618, 621,
+ 624, 625, 628, 632, 636, 642, 643, 646, 647, 648,
+ 654, 659, 664, 665, 666, 677, 680, 681, 688, 689,
+ 690, 693, 696
};
#endif
case 52:
#line 321 "ael.y"
{
- asprintf(&(yyval.str), "%s:%s:%s", (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str), (yyvsp[(5) - (5)].str));
- free((yyvsp[(1) - (5)].str));
- free((yyvsp[(3) - (5)].str));
- free((yyvsp[(5) - (5)].str)); ;}
+ if (asprintf(&(yyval.str), "%s:%s:%s", (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str), (yyvsp[(5) - (5)].str)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ (yyval.str) = NULL;
+ } else {
+ free((yyvsp[(1) - (5)].str));
+ free((yyvsp[(3) - (5)].str));
+ free((yyvsp[(5) - (5)].str));
+ }
+ ;}
break;
case 53:
-#line 326 "ael.y"
+#line 331 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str); ;}
break;
case 54:
-#line 330 "ael.y"
+#line 335 "ael.y"
{
(yyval.pval) = nword((yyvsp[(1) - (7)].str), &(yylsp[(1) - (7)]));
(yyval.pval)->next = nword((yyvsp[(3) - (7)].str), &(yylsp[(3) - (7)]));
break;
case 55:
-#line 338 "ael.y"
+#line 343 "ael.y"
{ reset_parencount(parseio->scanner); ;}
break;
case 56:
-#line 338 "ael.y"
+#line 343 "ael.y"
{ (yyval.str) = (yyvsp[(3) - (4)].str); ;}
break;
case 57:
-#line 342 "ael.y"
+#line 347 "ael.y"
{
(yyval.pval)= npval2(PV_IF, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)]));
(yyval.pval)->u1.str = (yyvsp[(2) - (2)].str); ;}
break;
case 58:
-#line 345 "ael.y"
+#line 350 "ael.y"
{
(yyval.pval) = npval2(PV_RANDOM, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)]));
(yyval.pval)->u1.str=(yyvsp[(2) - (2)].str);;}
break;
case 59:
-#line 348 "ael.y"
+#line 353 "ael.y"
{
(yyval.pval) = npval2(PV_IFTIME, &(yylsp[(1) - (4)]), &(yylsp[(4) - (4)]));
(yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval);
break;
case 60:
-#line 359 "ael.y"
+#line 364 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str);;}
break;
case 61:
-#line 360 "ael.y"
+#line 365 "ael.y"
{
- asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str));
- free((yyvsp[(1) - (2)].str));
- free((yyvsp[(2) - (2)].str));
- prev_word = (yyval.str);;}
+ if (asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ (yyval.str) = NULL;
+ } else {
+ free((yyvsp[(1) - (2)].str));
+ free((yyvsp[(2) - (2)].str));
+ prev_word = (yyval.str);
+ }
+ ;}
break;
case 62:
-#line 367 "ael.y"
+#line 377 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str); ;}
break;
case 63:
-#line 368 "ael.y"
+#line 378 "ael.y"
{
- asprintf(&((yyval.str)), "%s %s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str));
- free((yyvsp[(1) - (2)].str));
- free((yyvsp[(2) - (2)].str)); ;}
+ if (asprintf(&((yyval.str)), "%s %s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ (yyval.str) = NULL;
+ } else {
+ free((yyvsp[(1) - (2)].str));
+ free((yyvsp[(2) - (2)].str));
+ }
+ ;}
break;
case 64:
-#line 372 "ael.y"
+#line 387 "ael.y"
{
- asprintf(&((yyval.str)), "%s:%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str));
- free((yyvsp[(1) - (3)].str));
- free((yyvsp[(3) - (3)].str)); ;}
+ if (asprintf(&((yyval.str)), "%s:%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ (yyval.str) = NULL;
+ } else {
+ free((yyvsp[(1) - (3)].str));
+ free((yyvsp[(3) - (3)].str));
+ }
+ ;}
break;
case 65:
-#line 376 "ael.y"
+#line 396 "ael.y"
{ /* there are often '&' in hints */
- asprintf(&((yyval.str)), "%s&%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str));
- free((yyvsp[(1) - (3)].str));
- free((yyvsp[(3) - (3)].str));;}
+ if (asprintf(&((yyval.str)), "%s&%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ (yyval.str) = NULL;
+ } else {
+ free((yyvsp[(1) - (3)].str));
+ free((yyvsp[(3) - (3)].str));
+ }
+ ;}
break;
case 66:
-#line 382 "ael.y"
+#line 407 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str);;}
break;
case 67:
-#line 383 "ael.y"
+#line 408 "ael.y"
{
- asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str));
- free((yyvsp[(1) - (2)].str));
- free((yyvsp[(2) - (2)].str));
- prev_word = (yyval.str);;}
+ if (asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ (yyval.str) = NULL;
+ } else {
+ free((yyvsp[(1) - (2)].str));
+ free((yyvsp[(2) - (2)].str));
+ prev_word = (yyval.str);
+ }
+ ;}
break;
case 68:
-#line 388 "ael.y"
+#line 418 "ael.y"
{
- asprintf(&((yyval.str)), "%s%s%s", (yyvsp[(1) - (3)].str), (yyvsp[(2) - (3)].str), (yyvsp[(3) - (3)].str));
- free((yyvsp[(1) - (3)].str));
- free((yyvsp[(2) - (3)].str));
- free((yyvsp[(3) - (3)].str));
- prev_word=(yyval.str);;}
+ if (asprintf(&((yyval.str)), "%s%s%s", (yyvsp[(1) - (3)].str), (yyvsp[(2) - (3)].str), (yyvsp[(3) - (3)].str)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ (yyval.str) = NULL;
+ } else {
+ free((yyvsp[(1) - (3)].str));
+ free((yyvsp[(2) - (3)].str));
+ free((yyvsp[(3) - (3)].str));
+ prev_word=(yyval.str);
+ }
+ ;}
break;
case 69:
-#line 396 "ael.y"
+#line 431 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str);;}
break;
case 70:
-#line 397 "ael.y"
+#line 432 "ael.y"
{
- asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str));
- free((yyvsp[(1) - (2)].str));
- free((yyvsp[(2) - (2)].str));;}
+ if (asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ (yyval.str) = NULL;
+ } else {
+ free((yyvsp[(1) - (2)].str));
+ free((yyvsp[(2) - (2)].str));
+ }
+ ;}
break;
case 71:
-#line 401 "ael.y"
+#line 441 "ael.y"
{
- asprintf(&((yyval.str)), "%s:%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str));
- free((yyvsp[(1) - (3)].str));
- free((yyvsp[(3) - (3)].str));;}
+ if (asprintf(&((yyval.str)), "%s:%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ (yyval.str) = NULL;
+ } else {
+ free((yyvsp[(1) - (3)].str));
+ free((yyvsp[(3) - (3)].str));
+ }
+ ;}
break;
case 72:
-#line 407 "ael.y"
+#line 452 "ael.y"
{
(yyval.pval) = npval2(PV_SWITCH, &(yylsp[(1) - (5)]), &(yylsp[(5) - (5)]));
(yyval.pval)->u1.str = (yyvsp[(2) - (5)].str);
break;
case 73:
-#line 416 "ael.y"
+#line 461 "ael.y"
{
(yyval.pval) = npval2(PV_STATEMENTBLOCK, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.list = (yyvsp[(2) - (3)].pval); set_dads((yyval.pval),(yyvsp[(2) - (3)].pval));;}
break;
case 74:
-#line 419 "ael.y"
+#line 464 "ael.y"
{ (yyval.pval) = (yyvsp[(1) - (1)].pval); ;}
break;
case 75:
-#line 420 "ael.y"
+#line 465 "ael.y"
{ (yyval.pval) = (yyvsp[(1) - (1)].pval); ;}
break;
case 76:
-#line 421 "ael.y"
+#line 466 "ael.y"
{
(yyval.pval) = npval2(PV_GOTO, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.list = (yyvsp[(2) - (3)].pval);;}
break;
case 77:
-#line 424 "ael.y"
+#line 469 "ael.y"
{
(yyval.pval) = npval2(PV_GOTO, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.list = (yyvsp[(2) - (3)].pval);;}
break;
case 78:
-#line 427 "ael.y"
+#line 472 "ael.y"
{
(yyval.pval) = npval2(PV_LABEL, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)]));
(yyval.pval)->u1.str = (yyvsp[(1) - (2)].str); ;}
break;
case 79:
-#line 430 "ael.y"
+#line 475 "ael.y"
{reset_semicount(parseio->scanner);;}
break;
case 80:
-#line 431 "ael.y"
+#line 476 "ael.y"
{reset_semicount(parseio->scanner);;}
break;
case 81:
-#line 432 "ael.y"
+#line 477 "ael.y"
{reset_parencount(parseio->scanner);;}
break;
case 82:
-#line 432 "ael.y"
+#line 477 "ael.y"
{ /* XXX word_list maybe ? */
(yyval.pval) = npval2(PV_FOR, &(yylsp[(1) - (12)]), &(yylsp[(12) - (12)]));
(yyval.pval)->u1.for_init = (yyvsp[(4) - (12)].str);
break;
case 83:
-#line 438 "ael.y"
+#line 483 "ael.y"
{
(yyval.pval) = npval2(PV_WHILE, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.str = (yyvsp[(2) - (3)].str);
break;
case 84:
-#line 442 "ael.y"
+#line 487 "ael.y"
{ (yyval.pval) = (yyvsp[(1) - (1)].pval); ;}
break;
case 85:
-#line 443 "ael.y"
+#line 488 "ael.y"
{ (yyval.pval) = update_last((yyvsp[(2) - (3)].pval), &(yylsp[(2) - (3)])); ;}
break;
case 86:
-#line 444 "ael.y"
+#line 489 "ael.y"
{ (yyval.pval) = update_last((yyvsp[(1) - (2)].pval), &(yylsp[(2) - (2)])); ;}
break;
case 87:
-#line 445 "ael.y"
+#line 490 "ael.y"
{
(yyval.pval)= npval2(PV_APPLICATION_CALL, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)]));
(yyval.pval)->u1.str = (yyvsp[(1) - (2)].str);;}
break;
case 88:
-#line 448 "ael.y"
+#line 493 "ael.y"
{reset_semicount(parseio->scanner);;}
break;
case 89:
-#line 448 "ael.y"
+#line 493 "ael.y"
{
char *bufx;
int tot=0;
break;
case 90:
-#line 481 "ael.y"
+#line 526 "ael.y"
{ (yyval.pval) = npval2(PV_BREAK, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); ;}
break;
case 91:
-#line 482 "ael.y"
+#line 527 "ael.y"
{ (yyval.pval) = npval2(PV_RETURN, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); ;}
break;
case 92:
-#line 483 "ael.y"
+#line 528 "ael.y"
{ (yyval.pval) = npval2(PV_CONTINUE, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); ;}
break;
case 93:
-#line 484 "ael.y"
+#line 529 "ael.y"
{
(yyval.pval) = update_last((yyvsp[(1) - (3)].pval), &(yylsp[(2) - (3)]));
(yyval.pval)->u2.statements = (yyvsp[(2) - (3)].pval); set_dads((yyval.pval),(yyvsp[(2) - (3)].pval));
break;
case 94:
-#line 488 "ael.y"
+#line 533 "ael.y"
{ (yyval.pval)=0; ;}
break;
case 95:
-#line 491 "ael.y"
+#line 536 "ael.y"
{ (yyval.pval) = (yyvsp[(2) - (2)].pval); ;}
break;
case 96:
-#line 492 "ael.y"
+#line 537 "ael.y"
{ (yyval.pval) = NULL ; ;}
break;
case 97:
-#line 495 "ael.y"
+#line 540 "ael.y"
{ (yyval.pval) = nword((yyvsp[(1) - (1)].str), &(yylsp[(1) - (1)])); ;}
break;
case 98:
-#line 496 "ael.y"
+#line 541 "ael.y"
{
(yyval.pval) = nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)]));
(yyval.pval)->next = nword((yyvsp[(3) - (3)].str), &(yylsp[(3) - (3)])); ;}
break;
case 99:
-#line 499 "ael.y"
+#line 544 "ael.y"
{
(yyval.pval) = nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)]));
(yyval.pval)->next = nword((yyvsp[(3) - (3)].str), &(yylsp[(3) - (3)])); ;}
break;
case 100:
-#line 502 "ael.y"
+#line 547 "ael.y"
{
(yyval.pval) = nword((yyvsp[(1) - (5)].str), &(yylsp[(1) - (5)]));
(yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)]));
break;
case 101:
-#line 506 "ael.y"
+#line 551 "ael.y"
{
(yyval.pval) = nword((yyvsp[(1) - (5)].str), &(yylsp[(1) - (5)]));
(yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)]));
break;
case 102:
-#line 510 "ael.y"
+#line 555 "ael.y"
{
(yyval.pval) = nword(strdup("default"), &(yylsp[(1) - (5)]));
(yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)]));
break;
case 103:
-#line 514 "ael.y"
+#line 559 "ael.y"
{
(yyval.pval) = nword(strdup("default"), &(yylsp[(1) - (5)]));
(yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)]));
break;
case 104:
-#line 520 "ael.y"
+#line 565 "ael.y"
{ (yyval.str) = strdup("1"); ;}
break;
case 105:
-#line 521 "ael.y"
+#line 566 "ael.y"
{ (yyval.str) = (yyvsp[(2) - (2)].str); ;}
break;
case 106:
-#line 525 "ael.y"
+#line 570 "ael.y"
{ /* ext[, pri] default 1 */
(yyval.pval) = nword((yyvsp[(1) - (2)].str), &(yylsp[(1) - (2)]));
(yyval.pval)->next = nword((yyvsp[(2) - (2)].str), &(yylsp[(2) - (2)])); ;}
break;
case 107:
-#line 528 "ael.y"
+#line 573 "ael.y"
{ /* context, ext, pri */
(yyval.pval) = nword((yyvsp[(4) - (4)].str), &(yylsp[(4) - (4)]));
(yyval.pval)->next = nword((yyvsp[(1) - (4)].str), &(yylsp[(1) - (4)]));
break;
case 108:
-#line 534 "ael.y"
+#line 579 "ael.y"
{reset_argcount(parseio->scanner);;}
break;
case 109:
-#line 534 "ael.y"
+#line 579 "ael.y"
{
/* XXX original code had @2 but i think we need @5 */
(yyval.pval) = npval2(PV_MACRO_CALL, &(yylsp[(1) - (5)]), &(yylsp[(5) - (5)]));
break;
case 110:
-#line 539 "ael.y"
+#line 584 "ael.y"
{
(yyval.pval)= npval2(PV_MACRO_CALL, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.str = (yyvsp[(1) - (3)].str); ;}
break;
case 111:
-#line 547 "ael.y"
+#line 592 "ael.y"
{reset_argcount(parseio->scanner);;}
break;
case 112:
-#line 547 "ael.y"
+#line 592 "ael.y"
{
if (strcasecmp((yyvsp[(1) - (3)].str),"goto") == 0) {
(yyval.pval) = npval2(PV_GOTO, &(yylsp[(1) - (3)]), &(yylsp[(2) - (3)]));
break;
case 113:
-#line 558 "ael.y"
+#line 603 "ael.y"
{
(yyval.pval) = update_last((yyvsp[(1) - (3)].pval), &(yylsp[(3) - (3)]));
if( (yyval.pval)->type == PV_GOTO )
break;
case 114:
-#line 565 "ael.y"
+#line 610 "ael.y"
{ (yyval.pval) = update_last((yyvsp[(1) - (2)].pval), &(yylsp[(2) - (2)])); ;}
break;
case 115:
-#line 568 "ael.y"
+#line 613 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str) ;}
break;
case 116:
-#line 569 "ael.y"
+#line 614 "ael.y"
{ (yyval.str) = strdup(""); ;}
break;
case 117:
-#line 572 "ael.y"
+#line 617 "ael.y"
{ (yyval.pval) = nword((yyvsp[(1) - (1)].str), &(yylsp[(1) - (1)])); ;}
break;
case 118:
-#line 573 "ael.y"
+#line 618 "ael.y"
{
(yyval.pval)= npval(PV_WORD,0/*@1.first_line*/,0/*@1.last_line*/,0/* @1.first_column*/, 0/*@1.last_column*/);
(yyval.pval)->u1.str = strdup(""); ;}
break;
case 119:
-#line 576 "ael.y"
+#line 621 "ael.y"
{ (yyval.pval) = linku1((yyvsp[(1) - (3)].pval), nword((yyvsp[(3) - (3)].str), &(yylsp[(3) - (3)]))); ;}
break;
case 120:
-#line 579 "ael.y"
+#line 624 "ael.y"
{ (yyval.pval) = NULL; ;}
break;
case 121:
-#line 580 "ael.y"
+#line 625 "ael.y"
{ (yyval.pval) = linku1((yyvsp[(1) - (2)].pval), (yyvsp[(2) - (2)].pval)); ;}
break;
case 122:
-#line 583 "ael.y"
+#line 628 "ael.y"
{
(yyval.pval) = npval2(PV_CASE, &(yylsp[(1) - (4)]), &(yylsp[(3) - (4)])); /* XXX 3 or 4 ? */
(yyval.pval)->u1.str = (yyvsp[(2) - (4)].str);
break;
case 123:
-#line 587 "ael.y"
+#line 632 "ael.y"
{
(yyval.pval) = npval2(PV_DEFAULT, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.str = NULL;
break;
case 124:
-#line 591 "ael.y"
+#line 636 "ael.y"
{
(yyval.pval) = npval2(PV_PATTERN, &(yylsp[(1) - (4)]), &(yylsp[(4) - (4)])); /* XXX@3 or @4 ? */
(yyval.pval)->u1.str = (yyvsp[(2) - (4)].str);
break;
case 125:
-#line 597 "ael.y"
+#line 642 "ael.y"
{ (yyval.pval) = NULL; ;}
break;
case 126:
-#line 598 "ael.y"
+#line 643 "ael.y"
{ (yyval.pval) = linku1((yyvsp[(1) - (2)].pval), (yyvsp[(2) - (2)].pval)); ;}
break;
case 127:
-#line 601 "ael.y"
+#line 646 "ael.y"
{(yyval.pval)=(yyvsp[(1) - (1)].pval);;}
break;
case 128:
-#line 602 "ael.y"
+#line 647 "ael.y"
{ (yyval.pval)=(yyvsp[(1) - (1)].pval);;}
break;
case 129:
-#line 603 "ael.y"
+#line 648 "ael.y"
{
(yyval.pval) = npval2(PV_CATCH, &(yylsp[(1) - (5)]), &(yylsp[(5) - (5)]));
(yyval.pval)->u1.str = (yyvsp[(2) - (5)].str);
break;
case 130:
-#line 609 "ael.y"
+#line 654 "ael.y"
{
(yyval.pval) = npval2(PV_SWITCHES, &(yylsp[(1) - (4)]), &(yylsp[(2) - (4)]));
(yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval); set_dads((yyval.pval),(yyvsp[(3) - (4)].pval));;}
break;
case 131:
-#line 614 "ael.y"
+#line 659 "ael.y"
{
(yyval.pval) = npval2(PV_ESWITCHES, &(yylsp[(1) - (4)]), &(yylsp[(2) - (4)]));
(yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval); set_dads((yyval.pval),(yyvsp[(3) - (4)].pval));;}
break;
case 132:
-#line 619 "ael.y"
+#line 664 "ael.y"
{ (yyval.pval) = NULL; ;}
break;
case 133:
-#line 620 "ael.y"
+#line 665 "ael.y"
{ (yyval.pval) = linku1(nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)])), (yyvsp[(3) - (3)].pval)); ;}
break;
case 134:
-#line 621 "ael.y"
- { char *x; asprintf(&x,"%s@%s", (yyvsp[(1) - (5)].str),(yyvsp[(3) - (5)].str)); free((yyvsp[(1) - (5)].str)); free((yyvsp[(3) - (5)].str));
- (yyval.pval) = linku1(nword(x, &(yylsp[(1) - (5)])), (yyvsp[(5) - (5)].pval));;}
+#line 666 "ael.y"
+ {
+ char *x;
+ if (asprintf(&x,"%s@%s", (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str)) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ (yyval.pval) = NULL;
+ } else {
+ free((yyvsp[(1) - (5)].str));
+ free((yyvsp[(3) - (5)].str));
+ (yyval.pval) = linku1(nword(x, &(yylsp[(1) - (5)])), (yyvsp[(5) - (5)].pval));
+ }
+ ;}
break;
case 135:
-#line 623 "ael.y"
+#line 677 "ael.y"
{(yyval.pval)=(yyvsp[(2) - (2)].pval);;}
break;
case 136:
-#line 626 "ael.y"
+#line 680 "ael.y"
{ (yyval.pval) = nword((yyvsp[(1) - (1)].str), &(yylsp[(1) - (1)])); ;}
break;
case 137:
-#line 627 "ael.y"
+#line 681 "ael.y"
{
(yyval.pval) = nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)]));
(yyval.pval)->u2.arglist = (yyvsp[(3) - (3)].pval);
break;
case 138:
-#line 634 "ael.y"
+#line 688 "ael.y"
{ (yyval.pval) = (yyvsp[(1) - (2)].pval); ;}
break;
case 139:
-#line 635 "ael.y"
+#line 689 "ael.y"
{ (yyval.pval) = linku1((yyvsp[(1) - (3)].pval), (yyvsp[(2) - (3)].pval)); ;}
break;
case 140:
-#line 636 "ael.y"
+#line 690 "ael.y"
{(yyval.pval)=(yyvsp[(1) - (2)].pval);;}
break;
case 141:
-#line 639 "ael.y"
+#line 693 "ael.y"
{
(yyval.pval) = npval2(PV_INCLUDES, &(yylsp[(1) - (4)]), &(yylsp[(4) - (4)]));
(yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval);set_dads((yyval.pval),(yyvsp[(3) - (4)].pval));;}
break;
case 142:
-#line 642 "ael.y"
+#line 696 "ael.y"
{
(yyval.pval) = npval2(PV_INCLUDES, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));;}
break;
/* Line 1267 of yacc.c. */
-#line 3029 "ael.tab.c"
+#line 3083 "ael.tab.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
}
-#line 647 "ael.y"
+#line 701 "ael.y"
static char *token_equivs1[] =
* detect the '-' but only the ':' as separator
*/
timerange: word3_list COLON word3_list COLON word3_list {
- asprintf(&$$, "%s:%s:%s", $1, $3, $5);
- free($1);
- free($3);
- free($5); }
+ if (asprintf(&$$, "%s:%s:%s", $1, $3, $5) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ $$ = NULL;
+ } else {
+ free($1);
+ free($3);
+ free($5);
+ }
+ }
| word { $$ = $1; }
;
word_list : word { $$ = $1;}
| word word {
- asprintf(&($$), "%s%s", $1, $2);
- free($1);
- free($2);
- prev_word = $$;}
+ if (asprintf(&($$), "%s%s", $1, $2) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ $$ = NULL;
+ } else {
+ free($1);
+ free($2);
+ prev_word = $$;
+ }
+ }
;
hint_word : word { $$ = $1; }
| hint_word word {
- asprintf(&($$), "%s %s", $1, $2);
- free($1);
- free($2); }
+ if (asprintf(&($$), "%s %s", $1, $2) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ $$ = NULL;
+ } else {
+ free($1);
+ free($2);
+ }
+ }
| hint_word COLON word {
- asprintf(&($$), "%s:%s", $1, $3);
- free($1);
- free($3); }
+ if (asprintf(&($$), "%s:%s", $1, $3) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ $$ = NULL;
+ } else {
+ free($1);
+ free($3);
+ }
+ }
| hint_word AMPER word { /* there are often '&' in hints */
- asprintf(&($$), "%s&%s", $1, $3);
- free($1);
- free($3);}
-
+ if (asprintf(&($$), "%s&%s", $1, $3) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ $$ = NULL;
+ } else {
+ free($1);
+ free($3);
+ }
+ }
+ ;
word3_list : word { $$ = $1;}
| word word {
- asprintf(&($$), "%s%s", $1, $2);
- free($1);
- free($2);
- prev_word = $$;}
+ if (asprintf(&($$), "%s%s", $1, $2) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ $$ = NULL;
+ } else {
+ free($1);
+ free($2);
+ prev_word = $$;
+ }
+ }
| word word word {
- asprintf(&($$), "%s%s%s", $1, $2, $3);
- free($1);
- free($2);
- free($3);
- prev_word=$$;}
+ if (asprintf(&($$), "%s%s%s", $1, $2, $3) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ $$ = NULL;
+ } else {
+ free($1);
+ free($2);
+ free($3);
+ prev_word=$$;
+ }
+ }
;
goto_word : word { $$ = $1;}
| word word {
- asprintf(&($$), "%s%s", $1, $2);
- free($1);
- free($2);}
+ if (asprintf(&($$), "%s%s", $1, $2) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ $$ = NULL;
+ } else {
+ free($1);
+ free($2);
+ }
+ }
| goto_word COLON word {
- asprintf(&($$), "%s:%s", $1, $3);
- free($1);
- free($3);}
+ if (asprintf(&($$), "%s:%s", $1, $3) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ $$ = NULL;
+ } else {
+ free($1);
+ free($3);
+ }
+ }
;
switch_statement : KW_SWITCH test_expr LC case_statements RC {
switchlist : /* empty */ { $$ = NULL; }
| word SEMI switchlist { $$ = linku1(nword($1, &@1), $3); }
- | word AT word SEMI switchlist { char *x; asprintf(&x,"%s@%s", $1,$3); free($1); free($3);
- $$ = linku1(nword(x, &@1), $5);}
+ | word AT word SEMI switchlist {
+ char *x;
+ if (asprintf(&x,"%s@%s", $1, $3) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed\n");
+ $$ = NULL;
+ } else {
+ free($1);
+ free($3);
+ $$ = linku1(nword(x, &@1), $5);
+ }
+ }
| error switchlist {$$=$2;}
;
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-#if __STDC_VERSION__ >= 199901L
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
#define UINT32_MAX (4294967295U)
#endif
+#endif /* ! C99 */
+
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
#else /* ! __cplusplus */
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
#define YY_USE_CONST
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
-int ael_yylex_init (yyscan_t* scanner);
-
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
+typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define STORE_POS
#define STORE_LOC
#endif
-#line 953 "ael_lex.c"
+#line 948 "ael_lex.c"
#define INITIAL 0
#define paren 1
# define yylloc yyg->yylloc_r
+int ael_yylex_init (yyscan_t* scanner);
+
+int ael_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int ael_yylex (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
+extern int ael_yylex \
+ (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
-#define YY_DECL int ael_yylex (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
+#define YY_DECL int ael_yylex \
+ (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
#line 208 "ael.flex"
-#line 1198 "ael_lex.c"
+#line 1199 "ael_lex.c"
yylval = yylval_param;
#line 622 "ael.flex"
ECHO;
YY_BREAK
-#line 2003 "ael_lex.c"
+#line 2004 "ael_lex.c"
case YY_END_OF_BUFFER:
{
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- yyg->yy_n_chars, num_to_read );
+ yyg->yy_n_chars, (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
else
ret_val = EOB_ACT_CONTINUE_SCAN;
+ if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ael_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
yyg->yy_n_chars += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
yyg->yy_buffer_stack = (struct yy_buffer_state**)ael_yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
-
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in ael_yyensure_buffer_stack()" );
+
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc;
(yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in ael_yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
/** Setup the input buffer state to scan a string. The next call to ael_yylex() will
* scan from a @e copy of @a str.
- * @param str a NUL-terminated string to scan
+ * @param yystr a NUL-terminated string to scan
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
return yy_init_globals ( *ptr_yy_globals );
}
+/* ael_yylex_init_extra has the same functionality as ael_yylex_init, but follows the
+ * convention of taking the scanner as the last argument. Note however, that
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
+ * is the reason, too, why this function also must handle its own declaration).
+ * The user defined value in the first argument will be available to ael_yyalloc in
+ * the yyextra field.
+ */
+
+int ael_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
+
+{
+ struct yyguts_t dummy_yyguts;
+
+ ael_yyset_extra (yy_user_defined, &dummy_yyguts);
+
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) ael_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in
+ yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ ael_yyset_extra (yy_user_defined, *ptr_yy_globals);
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
my_file = strdup(filename);
stat(filename, &stats);
buffer = (char*)malloc(stats.st_size+2);
- fread(buffer, 1, stats.st_size, fin);
+ if (fread(buffer, 1, stats.st_size, fin) != stats.st_size) {
+ ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
+ }
buffer[stats.st_size]=0;
fclose(fin);
struct stat stats;
stat(fnamebuf2, &stats);
buffer = (char*)malloc(stats.st_size+1);
- fread(buffer, 1, stats.st_size, in1);
+ if (fread(buffer, 1, stats.st_size, in1) != stats.st_size) {
+ ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
+ }
buffer[stats.st_size] = 0;
ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size);
fclose(in1);
/* If it's voice, write it to the audio pipe */
if ((agi->audio > -1) && (f->frametype == AST_FRAME_VOICE)) {
/* Write, ignoring errors */
- write(agi->audio, f->data.ptr, f->datalen);
+ if (write(agi->audio, f->data.ptr, f->datalen) < 0) {
+ }
}
ast_frfree(f);
}
}
/* Table structure not cached; build the structure now */
- asprintf(&sql, sql_table_structure, tablename);
+ if (asprintf(&sql, sql_table_structure, tablename) < 0) {
+ ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ sql = NULL;
+ }
if (!(tblptr = ast_calloc(1, sizeof(*tblptr) + strlen(tablename) + 1))) {
AST_RWLIST_UNLOCK(&sqlite_tables);
ast_log(LOG_ERROR, "Memory error. Cannot cache table '%s'\n", tablename);
snprintf(prompt, sizeof(prompt), ">>>> passcode for %s key '%s': ",
key->ktype == AST_KEY_PRIVATE ? "PRIVATE" : "PUBLIC", key->name);
- write(key->outfd, prompt, strlen(prompt));
+ if (write(key->outfd, prompt, strlen(prompt)) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ key->infd = -2;
+ return -1;
+ }
memset(buf, 0, sizeof(buf));
tmp = ast_hide_password(key->infd);
memset(buf, 0, size);
while(!feof(f)) {
/* Calculate a "whatever" quality md5sum of the key */
char buf[256] = "";
- fgets(buf, sizeof(buf), f);
+ if (!fgets(buf, sizeof(buf), f)) {
+ continue;
+ }
if (!feof(f))
MD5Update(&md5, (unsigned char *) buf, strlen(buf));
}
num_to_read = contentlen;
}
- if(0 < num_to_read) {
- fread(&(buf[char_in_buf]), 1, num_to_read, fin);
+ if (0 < num_to_read) {
+ if (fread(&(buf[char_in_buf]), 1, num_to_read, fin) < num_to_read) {
+ ast_log(LOG_WARNING, "fread() failed: %s\n", strerror(errno));
+ num_to_read = 0;
+ }
contentlen -= num_to_read;
char_in_buf += num_to_read;
}
}
}
if (filespec) { /* If the file name path was found in the header */
- fwrite(buf, 1, marker, fout);
+ if (fwrite(buf, 1, marker, fout) != marker) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
x = (int)(path_end+1 - filespec);
- fwrite(filespec, 1, x, fout);
+ if (fwrite(filespec, 1, x, fout) != x) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
x = (int)(path_end+1 - buf);
memmove(buf, &(buf[x]), char_in_buf-x);
char_in_buf -= x;
if (0 > marker) {
if (char_in_buf < (boundary_len)) {
/*no possibility to find the boundary, write all you have */
- fwrite(buf, 1, char_in_buf, fout);
+ if (fwrite(buf, 1, char_in_buf, fout) != char_in_buf) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
char_in_buf = 0;
} else {
/* write all except for area where the boundary marker could be */
- fwrite(buf, 1, char_in_buf -(boundary_len -1), fout);
+ if (fwrite(buf, 1, char_in_buf -(boundary_len -1), fout) != char_in_buf - (boundary_len - 1)) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
x = char_in_buf -(boundary_len -1);
memmove(buf, &(buf[x]), char_in_buf-x);
char_in_buf = (boundary_len -1);
}
} else {
/* write up through the boundary, then look for filename in the rest */
- fwrite(buf, 1, marker + boundary_len, fout);
+ if (fwrite(buf, 1, marker + boundary_len, fout) != marker + boundary_len) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
x = marker + boundary_len;
memmove(buf, &(buf[x]), char_in_buf-x);
char_in_buf -= marker + boundary_len;
sprintf(secret, "%s%s", pak->id, client->password);
ast_sha1_hash(shasum, secret);
handshake = NULL;
- asprintf(&handshake, "<handshake>%s</handshake>", shasum);
- if (handshake) {
+ if (asprintf(&handshake, "<handshake>%s</handshake>", shasum) >= 0) {
aji_send_raw(client, handshake);
ast_free(handshake);
handshake = NULL;
}
if (!strchr(client->user, '/') && !client->component) { /*client */
resource = NULL;
- asprintf(&resource, "%s/asterisk", client->user);
- if (resource) {
+ if (asprintf(&resource, "%s/asterisk", client->user) >= 0) {
client->jid = iks_id_new(client->stack, resource);
ast_free(resource);
}
}
if (!strchr(client->user, '/') && !client->component) { /*client */
resource = NULL;
- asprintf(&resource, "%s/asterisk", client->user);
- if (resource) {
+ if (asprintf(&resource, "%s/asterisk", client->user) >= 0) {
client->jid = iks_id_new(client->stack, resource);
ast_free(resource);
}
ast_close_fds_above_n(STDERR_FILENO);
/* Child */
- chdir(class->dir);
+ if (chdir(class->dir) < 0) {
+ ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
+ _exit(1);
+ }
if (ast_test_flag(class, MOH_CUSTOM)) {
execv(argv[0], argv);
} else {
if (class->dir[0] != '/') {
ast_copy_string(dir_path, ast_config_AST_VAR_DIR, sizeof(dir_path));
- strncat(dir_path, "/", sizeof(dir_path));
- strncat(dir_path, class->dir, sizeof(dir_path));
+ strncat(dir_path, "/", sizeof(dir_path) - 1);
+ strncat(dir_path, class->dir, sizeof(dir_path) - 1);
} else {
ast_copy_string(dir_path, class->dir, sizeof(dir_path));
}
class->total_files = 0;
dirnamelen = strlen(dir_path) + 2;
- getcwd(path, sizeof(path));
- chdir(dir_path);
+ if (!getcwd(path, sizeof(path))) {
+ ast_log(LOG_WARNING, "getcwd() failed: %s\n", strerror(errno));
+ return -1;
+ }
+ if (chdir(path) < 0) {
+ ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
+ return -1;
+ }
while ((files_dirent = readdir(files_DIR))) {
/* The file name must be at least long enough to have the file type extension */
if ((strlen(files_dirent->d_name) < 4))
}
closedir(files_DIR);
- chdir(path);
+ if (chdir(path) < 0) {
+ ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
+ return -1;
+ }
if (ast_test_flag(class, MOH_SORTALPHA))
qsort(&class->filearray[0], class->total_files, sizeof(char *), moh_sort_compare);
return class->total_files;
ast_get_version(), buf, len, route->file->mime_type);
while ((len = read(fd, buf, sizeof(buf))) > 0) {
- fwrite(buf, 1, len, ser->f);
+ if (fwrite(buf, 1, len, ser->f) != len) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+ }
}
close(fd);
if (utime(argv[1], NULL)) {
/* Recreate the file if it doesn't exist */
if ((fd = open(argv[1], O_RDWR | O_TRUNC | O_CREAT, 0777)) > -1) {
- write(fd, explanation, strlen(explanation));
+ if (write(fd, explanation, strlen(explanation)) < 0) {
+ exit(1);
+ }
close(fd);
} else {
exit(1);
{
char stuff[4096];
va_list ap;
+ int res;
+
va_start(ap, fmt);
vsnprintf(stuff, sizeof(stuff), fmt, ap);
va_end(ap);
- write(fd, stuff, strlen(stuff));
+ if ((res = write(fd, stuff, strlen(stuff))) < 0) {
+ fprintf(stderr, "write() failed: %s\n", strerror(errno));
+ }
}
static char *get_header(struct message *m, char *var)
struct ast_mansession *s;
char tmp[4096];
va_list ap;
+ int res;
s = &session;
fdprintf(s->fd, "Action: %s\r\n", action);
va_start(ap, fmt);
vsnprintf(tmp, sizeof(tmp), fmt, ap);
va_end(ap);
- write(s->fd, tmp, strlen(tmp));
+ if ((res = write(s->fd, tmp, strlen(tmp))) < 0) {
+ fprintf(stderr, "write() failed: %s\n", strerror(errno));
+ }
fdprintf(s->fd, "\r\n");
return 0;
}
{
long i;
- i = ftell (anyin);
+ i = ftell(anyin);
if (i == -1) return FALSE;
- if (fseek (anyin, 0, SEEK_END) == -1) return FALSE;
- *result = ftell (anyin);
+ if (fseek(anyin, 0, SEEK_END) == -1) return FALSE;
+ *result = ftell(anyin);
if (*result == -1) return FALSE;
(*result) -= i;
(*result) /= samplewidth;
- if (fseek (anyin, i, SEEK_SET) == -1) return FALSE;
+ if (fseek(anyin, i, SEEK_SET) == -1) return FALSE;
return TRUE;
}
for (i = 0; i < 11; i++)
{
- fread( &tempint, 4, 1, anyin);
- printf( "%d: %d, ", i, tempint);
+ if (!fread( &tempint, 4, 1, anyin)) {
+ return;
+ }
+ printf( "%d: %d, ", i, tempint);
}
printf( "\n");
- fread( blood, 1, 8, anyin);
+ if (!fread( blood, 1, 8, anyin)) {
+ return;
+ }
for (i = 0; i < 8; i++)
- printf( "%d ", blood[i]);
+ printf( "%d ", blood[i]);
printf( "\n");
for (i = 0; i < 8; i++)
- {
- for (x = 128; x > 0; x /= 2)
- printf((blood[i] & x) == 0? "0 ":"1 ");
- printf(i%4==3? "\n":"| ");
- }
+ {
+ for (x = 128; x > 0; x /= 2)
+ printf((blood[i] & x) == 0? "0 ":"1 ");
+ printf(i%4==3? "\n":"| ");
+ }
printf( "\n");
for (i = 0; i < 2; i++)
{
- fread( &tempint, 4, 1, anyin);
- printf( "%d: %d, ", i, tempint);
+ if (!fread( &tempint, 4, 1, anyin)) {
+ return;
+ }
+ printf( "%d: %d, ", i, tempint);
}
printf( "\n");
for (i = 0; i < 2; i++)
{
- fread( &tempushort, 2, 1, anyin);
- printf( "%d: %d, ", i, tempushort);
+ if (!fread( &tempushort, 2, 1, anyin)) {
+ return;
+ }
+ printf( "%d: %d, ", i, tempushort);
}
printf( "\n");
}
iswav = FALSE;
if (ftell(anyin) == -1) /* If we cannot seek this file */
- {
- nowav = TRUE; /* -> Pretend this is no wav-file */
- chat("File not seekable: not checking for WAV-header.\n");
- }
+ {
+ nowav = TRUE; /* -> Pretend this is no wav-file */
+ chat("File not seekable: not checking for WAV-header.\n");
+ }
else
- {
- /* Expect four bytes "RIFF" and four bytes filelength */
- fread (str, 1, 8, anyin); /* 0 */
- str[4] = '\0';
- if (strcmp(str, "RIFF") != 0) nowav = TRUE;
- /* Expect eight bytes "WAVEfmt " */
- fread (str, 1, 8, anyin); /* 8 */
- str[8] = '\0';
- if (strcmp(str, "WAVEfmt ") != 0) nowav = TRUE;
- /* Expect length of fmt data, which should be 16 */
- fread (&tempuint, 4, 1, anyin); /* 16 */
- if (tempuint != 16) nowav = TRUE;
- /* Expect format tag, which should be 1 for pcm */
- fread (&tempushort, 2, 1, anyin); /* 20 */
- if (tempushort != 1)
- nowav = TRUE;
- /* Expect number of channels */
- fread (&cn, 2, 1, anyin); /* 20 */
- if (cn != 1 && cn != 2) nowav = TRUE;
- /* Read samplefrequency */
- fread (&sf, 4, 1, anyin); /* 24 */
- /* Read bytes per second: Should be samplefreq * channels * 2 */
- fread (&tempuint, 4, 1, anyin); /* 28 */
- if (tempuint != sf * cn * 2) nowav = TRUE;
- /* read bytes per frame: Should be channels * 2 */
- fread (&tempushort, 2, 1, anyin); /* 32 */
- if (tempushort != cn * 2) nowav = TRUE;
- /* Read bits per sample: Should be 16 */
- fread (&tempushort, 2, 1, anyin); /* 34 */
- if (tempushort != 16) nowav = TRUE;
- fread (str, 4, 1, anyin); /* 36 */
- str[4] = '\0';
- if (strcmp(str, "data") != 0) nowav = TRUE;
- fread (&tempuint, 4, 1, anyin); /* 40 */
- if (nowav)
- {
- fseek (anyin, 0, SEEK_SET); /* Back to beginning of file */
- chat("File has no WAV header.\n");
- }
- else
- {
- samplefrequency = sf;
- channels = cn;
- chat ("Read WAV header: %d channels, samplefrequency %d.\n",
- channels, samplefrequency);
- iswav = TRUE;
- }
- }
+ {
+ /* Expect four bytes "RIFF" and four bytes filelength */
+ if (!fread(str, 1, 8, anyin)) { /* 0 */
+ return;
+ }
+ str[4] = '\0';
+ if (strcmp(str, "RIFF") != 0) nowav = TRUE;
+ /* Expect eight bytes "WAVEfmt " */
+ if (!fread(str, 1, 8, anyin)) { /* 8 */
+ return;
+ }
+ str[8] = '\0';
+ if (strcmp(str, "WAVEfmt ") != 0) nowav = TRUE;
+ /* Expect length of fmt data, which should be 16 */
+ if (!fread(&tempuint, 4, 1, anyin)) { /* 16 */
+ return;
+ }
+ if (tempuint != 16) nowav = TRUE;
+ /* Expect format tag, which should be 1 for pcm */
+ if (!fread(&tempushort, 2, 1, anyin)) { /* 20 */
+ return;
+ }
+ if (tempushort != 1)
+ nowav = TRUE;
+ /* Expect number of channels */
+ if (!fread(&cn, 2, 1, anyin)) { /* 20 */
+ return;
+ }
+ if (cn != 1 && cn != 2) nowav = TRUE;
+ /* Read samplefrequency */
+ if (!fread(&sf, 4, 1, anyin)) { /* 24 */
+ return;
+ }
+ /* Read bytes per second: Should be samplefreq * channels * 2 */
+ if (!fread(&tempuint, 4, 1, anyin)) { /* 28 */
+ return;
+ }
+ if (tempuint != sf * cn * 2) nowav = TRUE;
+ /* read bytes per frame: Should be channels * 2 */
+ if (!fread(&tempushort, 2, 1, anyin)) { /* 32 */
+ return;
+ }
+ if (tempushort != cn * 2) nowav = TRUE;
+ /* Read bits per sample: Should be 16 */
+ if (!fread(&tempushort, 2, 1, anyin)) { /* 34 */
+ return;
+ }
+ if (tempushort != 16) nowav = TRUE;
+ if (!fread(str, 4, 1, anyin)) { /* 36 */
+ return;
+ }
+ str[4] = '\0';
+ if (strcmp(str, "data") != 0) nowav = TRUE;
+ if (!fread(&tempuint, 4, 1, anyin)) { /* 40 */
+ return;
+ }
+ if (nowav)
+ {
+ fseek(anyin, 0, SEEK_SET); /* Back to beginning of file */
+ chat("File has no WAV header.\n");
+ }
+ else
+ {
+ samplefrequency = sf;
+ channels = cn;
+ chat("Read WAV header: %d channels, samplefrequency %d.\n",
+ channels, samplefrequency);
+ iswav = TRUE;
+ }
+ }
return;
}
unsigned short tempushort;
/* If fseek fails, don't create the header. */
- if (fseek (out, 0, SEEK_END) != -1)
- {
- filelength = ftell (out);
- chat ("filelength %d, ", filelength);
- fseek (out, 0, SEEK_SET);
- fwrite ("RIFF", 1, 4, out); /* 0 */
- tempuint = filelength - 8; fwrite (&tempuint, 4, 1, out); /* 4 */
- fwrite ("WAVEfmt ", 1, 8, out); /* 8 */
- /* length of fmt data 16 bytes */
- tempuint = 16;
- fwrite (&tempuint, 4, 1, out); /* 16 */
- /* Format tag: 1 for pcm */
- tempushort = 1;
- fwrite (&tempushort, 2, 1, out); /* 20 */
- chat ("%d channels\n", channels);
- fwrite (&channels, 2, 1, out);
- chat ("samplefrequency %d\n", samplefrequency);
- fwrite (&samplefrequency, 4, 1, out); /* 24 */
- /* Bytes per second */
- tempuint = channels * samplefrequency * 2;
- fwrite (&tempuint, 4, 1, out); /* 28 */
- /* Block align */
- tempushort = 2 * channels;
- fwrite (&tempushort, 2, 1, out); /* 32 */
- /* Bits per sample */
- tempushort = 16;
- fwrite (&tempushort, 2, 1, out); /* 34 */
- fwrite ("data", 4, 1, out); /* 36 */
- tempuint = filelength - 44; fwrite (&tempuint, 4, 1, out); /* 40 */
- }
+ if (fseek(out, 0, SEEK_END) != -1)
+ {
+ filelength = ftell(out);
+ chat("filelength %d, ", filelength);
+ fseek(out, 0, SEEK_SET);
+ if (!fwrite("RIFF", 1, 4, out)) { /* 0 */
+ return;
+ }
+ tempuint = filelength - 8;
+ if (!fwrite(&tempuint, 4, 1, out)) { /* 4 */
+ return;
+ }
+ if (!fwrite("WAVEfmt ", 1, 8, out)) { /* 8 */
+ return;
+ }
+ /* length of fmt data 16 bytes */
+ tempuint = 16;
+ if (!fwrite(&tempuint, 4, 1, out)) { /* 16 */
+ return;
+ }
+ /* Format tag: 1 for pcm */
+ tempushort = 1;
+ if (!fwrite(&tempushort, 2, 1, out)) { /* 20 */
+ return;
+ }
+ chat("%d channels\n", channels);
+ if (!fwrite(&channels, 2, 1, out)) {
+ return;
+ }
+ chat("samplefrequency %d\n", samplefrequency);
+ if (!fwrite(&samplefrequency, 4, 1, out)) { /* 24 */
+ return;
+ }
+ /* Bytes per second */
+ tempuint = channels * samplefrequency * 2;
+ if (!fwrite(&tempuint, 4, 1, out)) { /* 28 */
+ return;
+ }
+ /* Block align */
+ tempushort = 2 * channels;
+ if (!fwrite(&tempushort, 2, 1, out)) { /* 32 */
+ return;
+ }
+ /* Bits per sample */
+ tempushort = 16;
+ if (!fwrite(&tempushort, 2, 1, out)) { /* 34 */
+ return;
+ }
+ if (!fwrite("data", 4, 1, out)) { /* 36 */
+ return;
+ }
+ tempuint = filelength - 44;
+ if (!fwrite(&tempuint, 4, 1, out)) { /* 40 */
+ return;
+ }
+ }
return;
}
case 0:
if (wavout)
makewavheader(); /* Writes a fully informed .WAV header */
- chat ("Success!\n");
+ chat("Success!\n");
break;
default:
- chat ("Failure.\n");
+ chat("Failure.\n");
break;
}
exit (value);
/* Call the routine that does the work */
if (!work (buffer, nowlength)) /* On error, stop. */
return FALSE;
- fwrite(buffer, sizeof(short), nowlength, theoutfile);
+ if (!fwrite(buffer, sizeof(short), nowlength, theoutfile)) {
+ return FALSE;
+ }
if (ferror( theoutfile) != 0)
fatalperror("Error writing to output file");
}
return -1;
}
while(!feof(f)) {
- fgets(buf, sizeof(buf), f);
+ if (!fgets(buf, sizeof(buf), f)) {
+ continue;
+ }
if (!feof(f)) {
lineno++;
val = strchr(buf, '#');
}
if (needfork) {
#ifndef HAVE_SBIN_LAUNCHD
- daemon(0,0);
+ if (daemon(0,0) < 0) {
+ fprintf(stderr, "daemon() failed: %s\n", strerror(errno));
+ exit(1);
+ }
#else
fprintf(stderr, "Mac OS X detected. Use 'launchd -d muted -f' to launch.\n");
exit(1);
for (; i < maxk; i++)
stereosample[2 * i + 1] = 0;
- fwrite(stereosample, sizeof(*leftsample), 2 * maxk, out);
- if (ferror( out) != 0)
- fatalerror("Error writing to file '%s': %s\n",
- outfilename, strerror(errno));
+ if (!fwrite(stereosample, sizeof(*leftsample), 2 * maxk, out)) {
+ fatalerror("Error writing to file '%s': %s\n",
+ outfilename, strerror(errno));
+ }
}
/* That was an endless loop. This point is never reached. */
}
select(2, NULL, &wfds, NULL, &tv);
- if (FD_ISSET(1, &wfds))
- write(1, buf, res);
+ if (FD_ISSET(1, &wfds)) {
+ if (write(1, buf, res) < 1) {
+ break;
+ }
+ }
}
close(s);