summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/chan_mobile.c4
-rw-r--r--apps/app_sms.c4
-rw-r--r--channels/chan_unistim.c4
-rw-r--r--main/asterisk.c5
-rw-r--r--main/format_pref.c5
-rw-r--r--main/jitterbuf.c8
-rw-r--r--main/stdtime/localtime.c6
-rw-r--r--main/tdd.c28
-rw-r--r--utils/extconf.c2
9 files changed, 43 insertions, 23 deletions
diff --git a/addons/chan_mobile.c b/addons/chan_mobile.c
index c9a9c8426..618d4e420 100644
--- a/addons/chan_mobile.c
+++ b/addons/chan_mobile.c
@@ -2119,7 +2119,7 @@ static int hfp_parse_ciev(struct hfp_pvt *hfp, char *buf, int *value)
return HFP_CIND_NONE;
}
- if (i >= sizeof(hfp->cind_state)) {
+ if (i >= ARRAY_LEN(hfp->cind_state)) {
ast_debug(2, "[%s] CIEV event index too high (%s)\n", hfp->owner->id, buf);
return HFP_CIND_NONE;
}
@@ -2601,7 +2601,7 @@ static int hfp_parse_cind_indicator(struct hfp_pvt *hfp, int group, char *indica
int value;
/* store the current indicator */
- if (group >= sizeof(hfp->cind_state)) {
+ if (group >= ARRAY_LEN(hfp->cind_state)) {
ast_debug(1, "ignoring CIND state '%s' for group %d, we only support up to %d indicators\n", indicator, group, (int) sizeof(hfp->cind_state));
return -1;
}
diff --git a/apps/app_sms.c b/apps/app_sms.c
index 2edc272bd..c7a0825e8 100644
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -1269,8 +1269,8 @@ static int sms_handleincoming_proto2(sms_t *h)
switch (msg) {
case 0x13: /* Body */
ast_verb(3, "SMS-P2 Body#%02X=[%.*s]\n", msg, msgsz, &h->imsg[f]);
- if (msgsz >= sizeof(h->imsg)) {
- msgsz = sizeof(h->imsg) - 1;
+ if (msgsz >= sizeof(h->ud)) {
+ msgsz = sizeof(h->ud) - 1;
}
for (i = 0; i < msgsz; i++) {
h->ud[i] = h->imsg[f + i];
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index 411d8f4e7..084df9f5d 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -4089,7 +4089,7 @@ static void key_main_page(struct unistimsession *pte, char keycode)
if (!ast_strlen_zero(pte->device->call_forward)) {
/* Cancel call forwarding */
memmove(pte->device->call_forward + 1, pte->device->call_forward,
- sizeof(pte->device->call_forward));
+ sizeof(pte->device->call_forward) - 1);
pte->device->call_forward[0] = '\0';
send_icon(TEXT_LINE0, FAV_ICON_NONE, pte);
pte->device->output = OUTPUT_HANDSET; /* Seems to be reseted somewhere */
@@ -6113,7 +6113,7 @@ static int parse_bookmark(const char *text, struct unistim_device *d)
ast_log(LOG_WARNING, "Invalid position %d for bookmark : already used\n:", p);
return 0;
}
- memmove(line, line + 2, sizeof(line));
+ memmove(line, line + 2, sizeof(line) - 2);
} else {
/* No position specified, looking for a free slot */
for (p = 0; p <= 5; p++) {
diff --git a/main/asterisk.c b/main/asterisk.c
index aaa9d03fc..937259cda 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -1104,6 +1104,11 @@ int ast_safe_system(const char *s)
void ast_console_toggle_loglevel(int fd, int level, int state)
{
int x;
+
+ if (level >= NUMLOGLEVELS) {
+ level = NUMLOGLEVELS - 1;
+ }
+
for (x = 0;x < AST_MAX_CONNECTS; x++) {
if (fd == consoles[x].fd) {
/*
diff --git a/main/format_pref.c b/main/format_pref.c
index 48fac7731..11308e1e0 100644
--- a/main/format_pref.c
+++ b/main/format_pref.c
@@ -195,6 +195,11 @@ void ast_codec_pref_prepend(struct ast_codec_pref *pref, struct ast_format *form
break;
}
+ /* If we failed to find any occurrence, set to the end */
+ if (x == AST_CODEC_PREF_SIZE) {
+ --x;
+ }
+
if (only_if_existing && !pref->order[x]) {
ast_format_list_destroy(f_list);
return;
diff --git a/main/jitterbuf.c b/main/jitterbuf.c
index 1ff261f47..1e7191f09 100644
--- a/main/jitterbuf.c
+++ b/main/jitterbuf.c
@@ -242,7 +242,9 @@ static void history_calc_maxbuf(jitterbuf *jb)
/* found where it fits */
if (toins > jb->hist_maxbuf[j]) {
/* move over */
- memmove(jb->hist_maxbuf + j + 1, jb->hist_maxbuf + j, (JB_HISTORY_MAXBUF_SZ - (j + 1)) * sizeof(jb->hist_maxbuf[0]));
+ if (j != JB_HISTORY_MAXBUF_SZ - 1) {
+ memmove(jb->hist_maxbuf + j + 1, jb->hist_maxbuf + j, (JB_HISTORY_MAXBUF_SZ - (j + 1)) * sizeof(jb->hist_maxbuf[0]));
+ }
/* insert */
jb->hist_maxbuf[j] = toins;
@@ -259,7 +261,9 @@ static void history_calc_maxbuf(jitterbuf *jb)
/* found where it fits */
if (toins < jb->hist_minbuf[j]) {
/* move over */
- memmove(jb->hist_minbuf + j + 1, jb->hist_minbuf + j, (JB_HISTORY_MAXBUF_SZ - (j + 1)) * sizeof(jb->hist_minbuf[0]));
+ if (j != JB_HISTORY_MAXBUF_SZ - 1) {
+ memmove(jb->hist_minbuf + j + 1, jb->hist_minbuf + j, (JB_HISTORY_MAXBUF_SZ - (j + 1)) * sizeof(jb->hist_minbuf[0]));
+ }
/* insert */
jb->hist_minbuf[j] = toins;
diff --git a/main/stdtime/localtime.c b/main/stdtime/localtime.c
index 3460307a2..7dd3a6928 100644
--- a/main/stdtime/localtime.c
+++ b/main/stdtime/localtime.c
@@ -2365,7 +2365,11 @@ char *ast_strptime_locale(const char *s, const char *format, struct ast_tm *tm,
prevlocale = ast_setlocale(locale);
res = strptime(s, format, &tm2);
ast_setlocale(prevlocale);
- memcpy(tm, &tm2, sizeof(*tm));
+ /* ast_time and tm are not the same size - tm is a subset of
+ * ast_time. Hence, the size of tm needs to be used for the
+ * memcpy
+ */
+ memcpy(tm, &tm2, sizeof(tm2));
tm->tm_usec = 0;
/* strptime(3) doesn't set .tm_isdst correctly, so to force ast_mktime(3)
* to deal with it correctly, we set it to -1. */
diff --git a/main/tdd.c b/main/tdd.c
index 1bdc020a3..6ceb31d66 100644
--- a/main/tdd.c
+++ b/main/tdd.c
@@ -69,19 +69,21 @@ static int tdd_decode_baudot(struct tdd_state *tdd,unsigned char data) /* covert
'5','\"',')','2','=','6','0','1',
'9','?','+','^','.','/',';','^' };
int d = 0; /* return 0 if not decodeable */
- switch (data) {
- case 0x1f:
- tdd->modo = 0;
- break;
- case 0x1b:
- tdd->modo = 1;
- break;
- default:
- if (tdd->modo == 0)
- d = ltrs[data];
- else
- d = figs[data];
- break;
+ if (data < 32) {
+ switch (data) {
+ case 0x1f:
+ tdd->modo = 0;
+ break;
+ case 0x1b:
+ tdd->modo = 1;
+ break;
+ default:
+ if (tdd->modo == 0)
+ d = ltrs[data];
+ else
+ d = figs[data];
+ break;
+ }
}
return d;
}
diff --git a/utils/extconf.c b/utils/extconf.c
index 20b2e5b2a..8245a161f 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -2910,7 +2910,7 @@ struct ast_timing {
unsigned int monthmask; /*!< Mask for month */
unsigned int daymask; /*!< Mask for date */
unsigned int dowmask; /*!< Mask for day of week (mon-sun) */
- unsigned int minmask[24]; /*!< Mask for minute */
+ unsigned int minmask[48]; /*!< Mask for minute */
char *timezone; /*!< NULL, or zoneinfo style timezone */
};
/* end of pbx.h */