Index: pbx/pbx_dundi.c =================================================================== --- pbx/pbx_dundi.c (revision 369969) +++ pbx/pbx_dundi.c (working copy) @@ -1384,8 +1384,6 @@ struct dundi_hdr *h; unsigned char *decrypt_space; decrypt_space = alloca(srclen); - if (!decrypt_space) - return NULL; decrypt_memcpy(decrypt_space, src->encdata, srclen, src->iv, &trans->dcx); /* Setup header */ h = (struct dundi_hdr *)dst; @@ -1412,60 +1410,57 @@ unsigned char iv[16]; len = pack->datalen + pack->datalen / 100 + 42; compress_space = alloca(len); - if (compress_space) { - memset(compress_space, 0, len); - /* We care about everthing save the first 6 bytes of header */ - bytes = len; - res = compress(compress_space, &bytes, pack->data + 6, pack->datalen - 6); - if (res != Z_OK) { - ast_debug(1, "Ouch, compression failed!\n"); + memset(compress_space, 0, len); + /* We care about everthing save the first 6 bytes of header */ + bytes = len; + res = compress(compress_space, &bytes, pack->data + 6, pack->datalen - 6); + if (res != Z_OK) { + ast_debug(1, "Ouch, compression failed!\n"); + return -1; + } + memset(&ied, 0, sizeof(ied)); + /* Say who we are */ + if (!pack->h->iseqno && !pack->h->oseqno) { + /* Need the key in the first copy */ + if (!(peer = find_peer(&trans->them_eid))) return -1; - } - memset(&ied, 0, sizeof(ied)); - /* Say who we are */ - if (!pack->h->iseqno && !pack->h->oseqno) { - /* Need the key in the first copy */ - if (!(peer = find_peer(&trans->them_eid))) - return -1; - if (update_key(peer)) - return -1; - if (!peer->sentfullkey) - ast_set_flag(trans, FLAG_SENDFULLKEY); - /* Append key data */ - dundi_ie_append_eid(&ied, DUNDI_IE_EID, &trans->us_eid); - if (ast_test_flag(trans, FLAG_SENDFULLKEY)) { - dundi_ie_append_raw(&ied, DUNDI_IE_SHAREDKEY, peer->txenckey, 128); - dundi_ie_append_raw(&ied, DUNDI_IE_SIGNATURE, peer->txenckey + 128, 128); - } else { - dundi_ie_append_int(&ied, DUNDI_IE_KEYCRC32, peer->us_keycrc32); - } - /* Setup contexts */ - trans->ecx = peer->us_ecx; - trans->dcx = peer->us_dcx; - - /* We've sent the full key */ - peer->sentfullkey = 1; - } - /* Build initialization vector */ - build_iv(iv); - /* Add the field, rounded up to 16 bytes */ - dundi_ie_append_encdata(&ied, DUNDI_IE_ENCDATA, iv, NULL, ((bytes + 15) / 16) * 16); - /* Copy the data */ - if ((ied.pos + bytes) >= sizeof(ied.buf)) { - ast_log(LOG_NOTICE, "Final packet too large!\n"); + if (update_key(peer)) return -1; + if (!peer->sentfullkey) + ast_set_flag(trans, FLAG_SENDFULLKEY); + /* Append key data */ + dundi_ie_append_eid(&ied, DUNDI_IE_EID, &trans->us_eid); + if (ast_test_flag(trans, FLAG_SENDFULLKEY)) { + dundi_ie_append_raw(&ied, DUNDI_IE_SHAREDKEY, peer->txenckey, 128); + dundi_ie_append_raw(&ied, DUNDI_IE_SIGNATURE, peer->txenckey + 128, 128); + } else { + dundi_ie_append_int(&ied, DUNDI_IE_KEYCRC32, peer->us_keycrc32); } - encrypt_memcpy(ied.buf + ied.pos, compress_space, bytes, iv, &trans->ecx); - ied.pos += ((bytes + 15) / 16) * 16; - /* Reconstruct header */ - pack->datalen = sizeof(struct dundi_hdr); - pack->h->cmdresp = DUNDI_COMMAND_ENCRYPT; - pack->h->cmdflags = 0; - memcpy(pack->h->ies, ied.buf, ied.pos); - pack->datalen += ied.pos; - return 0; + /* Setup contexts */ + trans->ecx = peer->us_ecx; + trans->dcx = peer->us_dcx; + + /* We've sent the full key */ + peer->sentfullkey = 1; } - return -1; + /* Build initialization vector */ + build_iv(iv); + /* Add the field, rounded up to 16 bytes */ + dundi_ie_append_encdata(&ied, DUNDI_IE_ENCDATA, iv, NULL, ((bytes + 15) / 16) * 16); + /* Copy the data */ + if ((ied.pos + bytes) >= sizeof(ied.buf)) { + ast_log(LOG_NOTICE, "Final packet too large!\n"); + return -1; + } + encrypt_memcpy(ied.buf + ied.pos, compress_space, bytes, iv, &trans->ecx); + ied.pos += ((bytes + 15) / 16) * 16; + /* Reconstruct header */ + pack->datalen = sizeof(struct dundi_hdr); + pack->h->cmdresp = DUNDI_COMMAND_ENCRYPT; + pack->h->cmdflags = 0; + memcpy(pack->h->ies, ied.buf, ied.pos); + pack->datalen += ied.pos; + return 0; } static int check_key(struct dundi_peer *peer, unsigned char *newkey, unsigned char *newsig, uint32_t keycrc32) @@ -1583,9 +1578,6 @@ if (datalen) { bufcpy = alloca(datalen); - if (!bufcpy) { - goto return_cleanup; - } /* Make a copy for parsing */ memcpy(bufcpy, hdr->ies, datalen); ast_debug(1, "Got canonical message %d (%d), %d bytes data%s\n", cmd, hdr->oseqno, datalen, final ? " (Final)" : ""); @@ -3769,16 +3761,15 @@ if (nummaps) { maps = alloca(nummaps * sizeof(*maps)); nummaps = 0; - if (maps) { - AST_LIST_TRAVERSE(&mappings, cur, list) { - if (!strcasecmp(cur->dcontext, context)) - maps[nummaps++] = *cur; - } + AST_LIST_TRAVERSE(&mappings, cur, list) { + if (!strcasecmp(cur->dcontext, context)) + maps[nummaps++] = *cur; } } AST_LIST_UNLOCK(&peers); - if (!nummaps || !maps) + if (!nummaps) { return -1; + } ttlms = DUNDI_FLUFF_TIME + ttl * DUNDI_TTL_TIME; memset(&dr2, 0, sizeof(dr2)); memset(&dr, 0, sizeof(dr)); Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 369969) +++ channels/chan_sip.c (working copy) @@ -23381,7 +23381,8 @@ payload_size = ast_connected_line_build_data(connected_line_data, sizeof(connected_line_data), &connected_to_target, NULL); frame_size = payload_size + sizeof(*frame_payload); - if (payload_size != -1 && (frame_payload = alloca(frame_size))) { + if (payload_size != -1) { + frame_payload = alloca(frame_size); frame_payload->payload_size = payload_size; memcpy(frame_payload->payload, connected_line_data, payload_size); frame_payload->action = AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO; @@ -27587,11 +27588,6 @@ } host = ast_strdupa(v->value); - if (!host) { - ast_log(LOG_WARNING, "Unable to allocate stack space for parsing outboundproxy\n"); - continue; - } - host = ast_skip_blanks(host); sep = strchr(host, ','); if (sep) { @@ -28565,11 +28561,6 @@ } host = ast_strdupa(v->value); - if (!host) { - ast_log(LOG_WARNING, "Unable to allocate stack space for parsing outboundproxy\n"); - continue; - } - host = ast_skip_blanks(host); sep = strchr(host, ','); if (sep) { Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 369969) +++ channels/chan_iax2.c (working copy) @@ -3034,10 +3034,7 @@ unsigned char sum[16], buf[1024]; char *s2, *last; - if (!(s2 = alloca(strlen(s) + 100))) { - ast_log(LOG_WARNING, "Alloca failed!\n"); - return -1; - } + s2 = alloca(strlen(s) + 100); last = strrchr(s, '/'); if (last) @@ -6304,8 +6301,6 @@ int padding; unsigned char *workspace; workspace = alloca(*datalen + 32); - if (!workspace) - return -1; if (ntohs(fh->scallno) & IAX_FLAG_FULL) { struct ast_iax2_full_enc_hdr *efh = (struct ast_iax2_full_enc_hdr *)fh; if (iaxdebug) Index: funcs/func_logic.c =================================================================== --- funcs/func_logic.c (revision 369969) +++ funcs/func_logic.c (working copy) @@ -251,16 +251,14 @@ if ((chan2 = ast_channel_get_by_name(args.channel))) { char *s = alloca(strlen(args.varname) + 4); - if (s) { - sprintf(s, "${%s}", args.varname); - ast_channel_lock(chan2); - if (buf) { - pbx_substitute_variables_helper(chan2, s, buf, len); - } else { - ast_str_substitute_variables(str, len, chan2, s); - } - ast_channel_unlock(chan2); + sprintf(s, "${%s}", args.varname); + ast_channel_lock(chan2); + if (buf) { + pbx_substitute_variables_helper(chan2, s, buf, len); + } else { + ast_str_substitute_variables(str, len, chan2, s); } + ast_channel_unlock(chan2); chan2 = ast_channel_unref(chan2); } } Index: funcs/func_cut.c =================================================================== --- funcs/func_cut.c (revision 369969) +++ funcs/func_cut.c (working copy) @@ -170,9 +170,8 @@ /* Check arguments */ if (args.argc < 3) { return ERROR_NOARG; - } else if (!(var_expr = alloca(strlen(args.varname) + 4))) { - return ERROR_NOMEM; } + var_expr = alloca(strlen(args.varname) + 4); /* Get the value of the variable named in the 1st argument */ snprintf(var_expr, strlen(args.varname) + 4, "${%s}", args.varname); Index: main/http.c =================================================================== --- main/http.c (revision 369969) +++ main/http.c (working copy) @@ -643,9 +643,7 @@ return NULL; } - if (!(buf = alloca(content_length))) { - return NULL; - } + buf = alloca(content_length); if (!fgets(buf, content_length, ser->f)) { return NULL; } Index: main/strcompat.c =================================================================== --- main/strcompat.c (revision 369969) +++ main/strcompat.c (working copy) @@ -68,12 +68,12 @@ unsigned char *buf; int buflen; - buflen = strlen(name) + strlen(value) + 2; - buf = alloca(buflen); - if (!overwrite && getenv(name)) return 0; + buflen = strlen(name) + strlen(value) + 2; + buf = alloca(buflen); + snprintf(buf, buflen, "%s=%s", name, value); return putenv(buf); @@ -105,23 +105,19 @@ char *strcasestr(const char *haystack, const char *needle) { char *u1, *u2; + char *offset; int u1len = strlen(haystack) + 1, u2len = strlen(needle) + 1; + if (u2len > u1len) { + /* Needle bigger than haystack */ + return NULL; + } u1 = alloca(u1len); u2 = alloca(u2len); - if (u1 && u2) { - char *offset; - if (u2len > u1len) { - /* Needle bigger than haystack */ - return NULL; - } - offset = strstr(upper(haystack, u1, u1len), upper(needle, u2, u2len)); - if (offset) { - /* Return the offset into the original string */ - return ((char *)((unsigned long)haystack + (unsigned long)(offset - u1))); - } else { - return NULL; - } + offset = strstr(upper(haystack, u1, u1len), upper(needle, u2, u2len)); + if (offset) { + /* Return the offset into the original string */ + return ((char *)((unsigned long)haystack + (unsigned long)(offset - u1))); } else { return NULL; } Index: main/pbx.c =================================================================== --- main/pbx.c (revision 369969) +++ main/pbx.c (working copy) @@ -10120,10 +10120,8 @@ struct ast_channel *chan2 = ast_channel_get_by_name(channel); if (chan2) { char *s = alloca(strlen(value) + 4); - if (s) { - sprintf(s, "${%s}", value); - pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1); - } + sprintf(s, "${%s}", value); + pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1); chan2 = ast_channel_unref(chan2); } pbx_builtin_setvar_helper(chan, name, tmp); Index: main/file.c =================================================================== --- main/file.c (revision 369969) +++ main/file.c (working copy) @@ -658,8 +658,6 @@ preflang = ""; buflen = strlen(preflang) + strlen(filename) + 4; buf = alloca(buflen); - if (buf == NULL) - return NULL; fmts = fileexists_core(filename, NULL, preflang, buf, buflen); if (fmts > 0) fmts &= AST_FORMAT_AUDIO_MASK; @@ -692,8 +690,6 @@ preflang = ""; buflen = strlen(preflang) + strlen(filename) + 4; buf = alloca(buflen); - if (buf == NULL) - return NULL; for (format = AST_FORMAT_FIRST_VIDEO_BIT; format <= AST_FORMAT_VIDEO_MASK; format = format << 1) { int fd; @@ -928,8 +924,6 @@ preflang = ""; buflen = strlen(preflang) + strlen(filename) + 4; /* room for everything */ buf = alloca(buflen); - if (buf == NULL) - return 0; return fileexists_core(filename, fmt, preflang, buf, buflen); }