aboutsummaryrefslogtreecommitdiffstats
path: root/agi
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-01 18:22:39 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-01 18:22:39 +0000
commitea96823f2626e2a4178eec54f8a78a666d376ac1 (patch)
treed6fd63606de3355d2e0f7bb2ab751116095a1451 /agi
parent1c4fdfd503883d806ba05da5d0e9156b54a4d51b (diff)
fix a bunch of potential problems found by gcc 4.3.x, primarily bare strings being passed to printf()-like functions and ignored results from read()/write() and friends
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@153337 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'agi')
-rw-r--r--agi/eagi-sphinx-test.c15
-rw-r--r--agi/eagi-test.c8
2 files changed, 16 insertions, 7 deletions
diff --git a/agi/eagi-sphinx-test.c b/agi/eagi-sphinx-test.c
index 0ad12c787..968e3cfc3 100644
--- a/agi/eagi-sphinx-test.c
+++ b/agi/eagi-sphinx-test.c
@@ -70,7 +70,9 @@ static int read_environment(void)
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';
@@ -121,7 +123,9 @@ static char *wait_result(void)
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;
@@ -132,9 +136,10 @@ static char *wait_result(void)
}
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)) {
diff --git a/agi/eagi-test.c b/agi/eagi-test.c
index 7745d18ae..9bfbee79e 100644
--- a/agi/eagi-test.c
+++ b/agi/eagi-test.c
@@ -24,7 +24,9 @@ static int read_environment(void)
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';
@@ -68,7 +70,9 @@ static char *wait_result(void)
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;