]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a bunch of off-by-one errors
authorTilghman Lesher <tilghman@meg.abyt.es>
Thu, 1 Oct 2009 23:53:12 +0000 (23:53 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Thu, 1 Oct 2009 23:53:12 +0000 (23:53 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@221776 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/asterisk.c
main/rtp.c
main/say.c

index d915b4bdb0cc26c294c5a61d24a4121d3ab4d280..c9413151297081615b05d15ac4bcff5669b7c263 100644 (file)
@@ -963,7 +963,7 @@ static void *netconsole(void *vconsole)
                        continue;
                }
                if (fds[0].revents) {
-                       res = read(con->fd, tmp, sizeof(tmp));
+                       res = read(con->fd, tmp, sizeof(tmp) - 1);
                        if (res < 1) {
                                break;
                        }
@@ -2144,7 +2144,7 @@ static char *cli_complete(EditLine *el, int ch)
        if (ast_opt_remote) {
                snprintf(buf, sizeof(buf),"_COMMAND NUMMATCHES \"%s\" \"%s\"", lf->buffer, ptr); 
                fdsend(ast_consock, buf);
-               res = read(ast_consock, buf, sizeof(buf));
+               res = read(ast_consock, buf, sizeof(buf) - 1);
                buf[res] = '\0';
                nummatches = atoi(buf);
 
index 770292a4f9e9e3bbe4d1a4871d44d04ab034a834..519ecf35cfc4b3eff697e69b2fc019044308b084 100644 (file)
@@ -1696,7 +1696,7 @@ int ast_rtp_make_compatible(struct ast_channel *dest, struct ast_channel *src, i
  */
 void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt) 
 {
-       if (pt < 0 || pt > MAX_RTP_PT || static_RTP_PT[pt].code == 0) 
+       if (pt < 0 || pt >= MAX_RTP_PT || static_RTP_PT[pt].code == 0) 
                return; /* bogus payload type */
 
        ast_mutex_lock(&rtp->bridge_lock);
@@ -1708,7 +1708,7 @@ void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt)
     an unknown media type */
 void ast_rtp_unset_m_type(struct ast_rtp* rtp, int pt) 
 {
-       if (pt < 0 || pt > MAX_RTP_PT)
+       if (pt < 0 || pt >= MAX_RTP_PT)
                return; /* bogus payload type */
 
        ast_mutex_lock(&rtp->bridge_lock);
@@ -1728,7 +1728,7 @@ int ast_rtp_set_rtpmap_type(struct ast_rtp *rtp, int pt,
        unsigned int i;
        int found = 0;
 
-       if (pt < 0 || pt > MAX_RTP_PT) 
+       if (pt < 0 || pt >= MAX_RTP_PT) 
                return -1; /* bogus payload type */
        
        ast_mutex_lock(&rtp->bridge_lock);
@@ -1780,7 +1780,7 @@ struct rtpPayloadType ast_rtp_lookup_pt(struct ast_rtp* rtp, int pt)
 
        result.isAstFormat = result.code = 0;
 
-       if (pt < 0 || pt > MAX_RTP_PT) 
+       if (pt < 0 || pt >= MAX_RTP_PT) 
                return result; /* bogus payload type */
 
        /* Start with negotiated codecs */
@@ -2846,7 +2846,7 @@ struct ast_codec_pref *ast_rtp_codec_getpref(struct ast_rtp *rtp)
 
 int ast_rtp_codec_getformat(int pt)
 {
-       if (pt < 0 || pt > MAX_RTP_PT)
+       if (pt < 0 || pt >= MAX_RTP_PT)
                return 0; /* bogus payload type */
 
        if (static_RTP_PT[pt].isAstFormat)
index 439855bf4a10dc077c3a78bb50da91d1cde59134..507c3c3e2f6cd0e44de1878530219a9d534c7171 100644 (file)
@@ -3254,7 +3254,7 @@ int ast_say_date_with_format_en(struct ast_channel *chan, time_t time, const cha
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset=0;
-                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                        sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                res = wait_file(chan,ints,sndfile,lang);
@@ -3502,7 +3502,7 @@ int ast_say_date_with_format_da(struct ast_channel *chan, time_t time, const cha
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset=0;
-                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                        sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                res = wait_file(chan,ints,sndfile,lang);
@@ -3707,7 +3707,7 @@ int ast_say_date_with_format_de(struct ast_channel *chan, time_t time, const cha
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset=0;
-                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                        sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                res = wait_file(chan,ints,sndfile,lang);
@@ -3939,7 +3939,7 @@ int ast_say_date_with_format_he(struct ast_channel *chan, time_t time, const cha
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset=0;
-                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                        sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                res = wait_file(chan,ints,sndfile,lang);
@@ -4094,7 +4094,7 @@ int ast_say_date_with_format_es(struct ast_channel *chan, time_t time, const cha
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset=0;
-                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                        sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                snprintf(nextmsg,sizeof(nextmsg), "%s", sndfile);
@@ -4286,7 +4286,7 @@ int ast_say_date_with_format_fr(struct ast_channel *chan, time_t time, const cha
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset=0;
-                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                        sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                res = wait_file(chan,ints,sndfile,lang);
@@ -4484,7 +4484,7 @@ int ast_say_date_with_format_it(struct ast_channel *chan, time_t time, const cha
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset=0;
-                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                res = wait_file(chan,ints,sndfile,lang);
@@ -4717,7 +4717,7 @@ int ast_say_date_with_format_nl(struct ast_channel *chan, time_t time, const cha
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset=0;
-                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                        sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                res = wait_file(chan,ints,sndfile,lang);
@@ -4923,7 +4923,7 @@ int ast_say_date_with_format_pl(struct ast_channel *chan, time_t thetime, const
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset = 0;
-                               for (sndoffset = 0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset = 0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                        sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                res = wait_file(chan, ints, sndfile, lang);
@@ -5141,7 +5141,7 @@ int ast_say_date_with_format_pt(struct ast_channel *chan, time_t time, const cha
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset=0;
-                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                        sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                snprintf(nextmsg,sizeof(nextmsg), "%s", sndfile);
@@ -5431,7 +5431,7 @@ int ast_say_date_with_format_zh(struct ast_channel *chan, time_t time, const cha
                        case '\'':
                                /* Literal name of a sound file */
                                sndoffset=0;
-                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                               for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                        sndfile[sndoffset] = format[offset];
                                sndfile[sndoffset] = '\0';
                                res = wait_file(chan,ints,sndfile,lang);
@@ -6808,7 +6808,7 @@ static int ast_say_date_with_format_gr(struct ast_channel *chan, time_t time, co
                case '\'':
                        /* Literal name of a sound file */
                        sndoffset=0;
-                       for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
+                       for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++)
                                sndfile[sndoffset] = format[offset];
                        sndfile[sndoffset] = '\0';
                        res = wait_file(chan,ints,sndfile,lang);