diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/acl.c | 6 | ||||
-rw-r--r-- | main/asterisk.c | 24 | ||||
-rw-r--r-- | main/cdr.c | 4 | ||||
-rw-r--r-- | main/channel.c | 4 | ||||
-rw-r--r-- | main/cli.c | 2 | ||||
-rw-r--r-- | main/config.c | 2 | ||||
-rw-r--r-- | main/dnsmgr.c | 2 | ||||
-rw-r--r-- | main/dsp.c | 2 | ||||
-rw-r--r-- | main/enum.c | 2 | ||||
-rw-r--r-- | main/features.c | 26 | ||||
-rw-r--r-- | main/frame.c | 2 | ||||
-rw-r--r-- | main/http.c | 2 | ||||
-rw-r--r-- | main/indications.c | 24 | ||||
-rw-r--r-- | main/manager.c | 14 | ||||
-rw-r--r-- | main/netsock.c | 2 | ||||
-rw-r--r-- | main/pbx.c | 16 | ||||
-rw-r--r-- | main/timing.c | 2 | ||||
-rw-r--r-- | main/utils.c | 6 |
18 files changed, 71 insertions, 71 deletions
diff --git a/main/acl.c b/main/acl.c index 3484c71db..fea76a62b 100644 --- a/main/acl.c +++ b/main/acl.c @@ -297,7 +297,7 @@ struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha nm++; if (!strchr(nm, '.')) { - if ((sscanf(nm, "%d", &x) == 1) && (x >= 0) && (x <= 32)) { + if ((sscanf(nm, "%30d", &x) == 1) && (x >= 0) && (x <= 32)) { ha->netmask.s_addr = htonl(0xFFFFFFFF << (32 - x)); } else { ast_log(LOG_WARNING, "Invalid CIDR in %s\n", stuff); @@ -423,7 +423,7 @@ int ast_str2cos(const char *value, unsigned int *cos) { int fval; - if (sscanf(value, "%d", &fval) == 1) { + if (sscanf(value, "%30d", &fval) == 1) { if (fval < 8) { *cos = fval; return 0; @@ -438,7 +438,7 @@ int ast_str2tos(const char *value, unsigned int *tos) int fval; unsigned int x; - if (sscanf(value, "%i", &fval) == 1) { + if (sscanf(value, "%30i", &fval) == 1) { *tos = fval & 0xFF; return 0; } diff --git a/main/asterisk.c b/main/asterisk.c index 3e9837641..dbf479314 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1389,7 +1389,7 @@ static int ast_makesocket(void) if (!ast_strlen_zero(ast_config_AST_CTL_PERMISSIONS)) { int p1; mode_t p; - sscanf(ast_config_AST_CTL_PERMISSIONS, "%o", &p1); + sscanf(ast_config_AST_CTL_PERMISSIONS, "%30o", &p1); p = p1; if ((chmod(ast_config_AST_SOCKET, p)) < 0) ast_log(LOG_WARNING, "Unable to change file permissions of %s: %s\n", ast_config_AST_SOCKET, strerror(errno)); @@ -2192,10 +2192,10 @@ static char *cli_prompt(EditLine *editline) switch (*t) { case 'C': /* color */ t++; - if (sscanf(t, "%d;%d%n", &fgcolor, &bgcolor, &i) == 2) { + if (sscanf(t, "%30d;%30d%n", &fgcolor, &bgcolor, &i) == 2) { ast_str_append(&prompt, 0, "%s", term_color_code(term_code, fgcolor, bgcolor, sizeof(term_code))); t += i - 1; - } else if (sscanf(t, "%d%n", &fgcolor, &i) == 1) { + } else if (sscanf(t, "%30d%n", &fgcolor, &i) == 1) { ast_str_append(&prompt, 0, "%s", term_color_code(term_code, fgcolor, 0, sizeof(term_code))); t += i - 1; } @@ -2236,7 +2236,7 @@ static char *cli_prompt(EditLine *editline) #ifdef HAVE_GETLOADAVG case 'l': /* load avg */ t++; - if (sscanf(t, "%d", &which) == 1 && which > 0 && which <= 3) { + if (sscanf(t, "%30d", &which) == 1 && which > 0 && which <= 3) { double list[3]; getloadavg(list, 3); ast_str_append(&prompt, 0, "%.2f", list[which - 1]); @@ -2878,7 +2878,7 @@ static void ast_readconfig(void) /* debug level (-d at startup) */ } else if (!strcasecmp(v->name, "debug")) { option_debug = 0; - if (sscanf(v->value, "%d", &option_debug) != 1) { + if (sscanf(v->value, "%30d", &option_debug) != 1) { option_debug = ast_true(v->value); } #if HAVE_WORKING_FORK @@ -2926,7 +2926,7 @@ static void ast_readconfig(void) } else if (!strcasecmp(v->name, "internal_timing")) { ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_INTERNAL_TIMING); } else if (!strcasecmp(v->name, "maxcalls")) { - if ((sscanf(v->value, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0)) { + if ((sscanf(v->value, "%30d", &option_maxcalls) != 1) || (option_maxcalls < 0)) { option_maxcalls = 0; } } else if (!strcasecmp(v->name, "maxload")) { @@ -2935,7 +2935,7 @@ static void ast_readconfig(void) if (getloadavg(test, 1) == -1) { ast_log(LOG_ERROR, "Cannot obtain load average on this system. 'maxload' option disabled.\n"); option_maxload = 0.0; - } else if ((sscanf(v->value, "%lf", &option_maxload) != 1) || (option_maxload < 0.0)) { + } else if ((sscanf(v->value, "%30lf", &option_maxload) != 1) || (option_maxload < 0.0)) { option_maxload = 0.0; } /* Set the maximum amount of open files */ @@ -2977,7 +2977,7 @@ static void ast_readconfig(void) } else if (!strcasecmp(v->name, "minmemfree")) { /* specify the minimum amount of free memory to retain. Asterisk should stop accepting new calls * if the amount of free memory falls below this watermark */ - if ((sscanf(v->value, "%ld", &option_minmemfree) != 1) || (option_minmemfree < 0)) { + if ((sscanf(v->value, "%30ld", &option_minmemfree) != 1) || (option_minmemfree < 0)) { option_minmemfree = 0; } #endif @@ -2998,7 +2998,7 @@ static void ast_readconfig(void) } for (v = ast_variable_browse(cfg, "compat"); v; v = v->next) { float version; - if (sscanf(v->value, "%f", &version) != 1) { + if (sscanf(v->value, "%30f", &version) != 1) { ast_log(LOG_WARNING, "Compatibility version for option '%s' is not a number: '%s'\n", v->name, v->value); continue; } @@ -3142,7 +3142,7 @@ int main(int argc, char *argv[]) switch (c) { #if defined(HAVE_SYSINFO) case 'e': - if ((sscanf(&optarg[1], "%ld", &option_minmemfree) != 1) || (option_minmemfree < 0)) { + if ((sscanf(&optarg[1], "%30ld", &option_minmemfree) != 1) || (option_minmemfree < 0)) { option_minmemfree = 0; } break; @@ -3182,11 +3182,11 @@ int main(int argc, char *argv[]) ast_set_flag(&ast_options, AST_OPT_FLAG_MUTE); break; case 'M': - if ((sscanf(optarg, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0)) + if ((sscanf(optarg, "%30d", &option_maxcalls) != 1) || (option_maxcalls < 0)) option_maxcalls = 0; break; case 'L': - if ((sscanf(optarg, "%lf", &option_maxload) != 1) || (option_maxload < 0.0)) + if ((sscanf(optarg, "%30lf", &option_maxload) != 1) || (option_maxload < 0.0)) option_maxload = 0.0; break; case 'q': diff --git a/main/cdr.c b/main/cdr.c index 0658ead75..69d4a8fe1 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -1493,7 +1493,7 @@ static int do_reload(int reload) batchsafeshutdown = ast_true(batchsafeshutdown_value); } if ((size_value = ast_variable_retrieve(config, "general", "size"))) { - if (sscanf(size_value, "%d", &cfg_size) < 1) + if (sscanf(size_value, "%30d", &cfg_size) < 1) ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", size_value); else if (cfg_size < 0) ast_log(LOG_WARNING, "Invalid maximum batch size '%d' specified, using default\n", cfg_size); @@ -1501,7 +1501,7 @@ static int do_reload(int reload) batchsize = cfg_size; } if ((time_value = ast_variable_retrieve(config, "general", "time"))) { - if (sscanf(time_value, "%d", &cfg_time) < 1) + if (sscanf(time_value, "%30d", &cfg_time) < 1) ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", time_value); else if (cfg_time < 0) ast_log(LOG_WARNING, "Invalid maximum batch time '%d' specified, using default\n", cfg_time); diff --git a/main/channel.c b/main/channel.c index f4f5d9013..65cc5b354 100644 --- a/main/channel.c +++ b/main/channel.c @@ -6144,9 +6144,9 @@ ast_group_t ast_get_group(const char *s) c = ast_strdupa(s); while ((piece = strsep(&c, ","))) { - if (sscanf(piece, "%d-%d", &start, &finish) == 2) { + if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) { /* Range */ - } else if (sscanf(piece, "%d", &start)) { + } else if (sscanf(piece, "%30d", &start)) { /* Just one */ finish = start; } else { diff --git a/main/cli.c b/main/cli.c index f3e3e6e22..5b31bba2b 100644 --- a/main/cli.c +++ b/main/cli.c @@ -444,7 +444,7 @@ static char *handle_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_arg atleast = 1; if (argc != e->args + atleast + 1 && argc != e->args + atleast + 2) return CLI_SHOWUSAGE; - if (sscanf(argv[e->args + atleast], "%d", &newlevel) != 1) + if (sscanf(argv[e->args + atleast], "%30d", &newlevel) != 1) return CLI_SHOWUSAGE; if (argc == e->args + atleast + 2) { unsigned int debug = (*what == 'C'); diff --git a/main/config.c b/main/config.c index c1805956e..f72654834 100644 --- a/main/config.c +++ b/main/config.c @@ -364,7 +364,7 @@ void ast_variable_insert(struct ast_category *category, struct ast_variable *var int lineno; int insertline; - if (!variable || sscanf(line, "%d", &insertline) != 1) { + if (!variable || sscanf(line, "%30d", &insertline) != 1) { return; } if (!insertline) { diff --git a/main/dnsmgr.c b/main/dnsmgr.c index 54d9467ee..a7bc9f58a 100644 --- a/main/dnsmgr.c +++ b/main/dnsmgr.c @@ -394,7 +394,7 @@ static int do_reload(int loading) enabled = ast_true(enabled_value); } if ((interval_value = ast_variable_retrieve(config, "general", "refreshinterval"))) { - if (sscanf(interval_value, "%d", &interval) < 1) + if (sscanf(interval_value, "%30d", &interval) < 1) ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", interval_value); else if (interval < 0) ast_log(LOG_WARNING, "Invalid refresh interval '%d' specified, using default\n", interval); diff --git a/main/dsp.c b/main/dsp.c index ab7cacf1a..83a6dd79b 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -1670,7 +1670,7 @@ static int _dsp_init(int reload) const char *value; value = ast_variable_retrieve(cfg, "default", "silencethreshold"); - if (value && sscanf(value, "%d", &thresholds[THRESHOLD_SILENCE]) != 1) { + if (value && sscanf(value, "%30d", &thresholds[THRESHOLD_SILENCE]) != 1) { ast_log(LOG_WARNING, "%s: '%s' is not a valid silencethreshold value\n", CONFIG_FILE_NAME, value); thresholds[THRESHOLD_SILENCE] = 256; } else if (!value) { diff --git a/main/enum.c b/main/enum.c index c8ff67e2b..416bb9072 100644 --- a/main/enum.c +++ b/main/enum.c @@ -114,7 +114,7 @@ static int cclen(const char *number) strncpy(digits, number, 2); - if (!sscanf(digits, "%d", &cc)) { + if (!sscanf(digits, "%30d", &cc)) { return 0; } diff --git a/main/features.c b/main/features.c index b0774c2b7..becb6eae7 100644 --- a/main/features.c +++ b/main/features.c @@ -657,7 +657,7 @@ static struct parkeduser *park_space_reserve(struct ast_channel *chan, * limitation here. If extout was not numeric, we could permit * arbitrary non-numeric extensions. */ - if (sscanf(parkingexten, "%d", &parking_space) != 1 || parking_space < 0) { + if (sscanf(parkingexten, "%30d", &parking_space) != 1 || parking_space < 0) { AST_LIST_UNLOCK(&parkinglot->parkings); parkinglot_unref(parkinglot); free(pu); @@ -3484,7 +3484,7 @@ static int park_call_exec(struct ast_channel *chan, const char *data) if (parse) { if (!ast_strlen_zero(app_args.timeout)) { - if (sscanf(app_args.timeout, "%d", &args.timeout) != 1) { + if (sscanf(app_args.timeout, "%30d", &args.timeout) != 1) { ast_log(LOG_WARNING, "Invalid timeout '%s' provided\n", app_args.timeout); args.timeout = 0; } @@ -3496,7 +3496,7 @@ static int park_call_exec(struct ast_channel *chan, const char *data) args.return_ext = app_args.return_ext; } if (!ast_strlen_zero(app_args.return_pri)) { - if (sscanf(app_args.return_pri, "%d", &args.return_pri) != 1) { + if (sscanf(app_args.return_pri, "%30d", &args.return_pri) != 1) { ast_log(LOG_WARNING, "Invalid priority '%s' specified\n", app_args.return_pri); args.return_pri = 0; } @@ -3765,13 +3765,13 @@ static struct ast_parkinglot *build_parkinglot(char *name, struct ast_variable * if (!strcasecmp(confvar->name, "context")) { ast_copy_string(parkinglot->parking_con, confvar->value, sizeof(parkinglot->parking_con)); } else if (!strcasecmp(confvar->name, "parkingtime")) { - if ((sscanf(confvar->value, "%d", &parkinglot->parkingtime) != 1) || (parkinglot->parkingtime < 1)) { + if ((sscanf(confvar->value, "%30d", &parkinglot->parkingtime) != 1) || (parkinglot->parkingtime < 1)) { ast_log(LOG_WARNING, "%s is not a valid parkingtime\n", confvar->value); parkinglot->parkingtime = DEFAULT_PARK_TIME; } else parkinglot->parkingtime = parkinglot->parkingtime * 1000; } else if (!strcasecmp(confvar->name, "parkpos")) { - if (sscanf(confvar->value, "%d-%d", &start, &end) != 2) { + if (sscanf(confvar->value, "%30d-%30d", &start, &end) != 2) { ast_log(LOG_WARNING, "Format for parking positions is a-b, where a and b are numbers at line %d of parking.conf\n", confvar->lineno); error = 1; } else { @@ -3935,13 +3935,13 @@ static int load_config(void) } else if (!strcasecmp(var->name, "context")) { ast_copy_string(default_parkinglot->parking_con, var->value, sizeof(default_parkinglot->parking_con)); } else if (!strcasecmp(var->name, "parkingtime")) { - if ((sscanf(var->value, "%d", &default_parkinglot->parkingtime) != 1) || (default_parkinglot->parkingtime < 1)) { + if ((sscanf(var->value, "%30d", &default_parkinglot->parkingtime) != 1) || (default_parkinglot->parkingtime < 1)) { ast_log(LOG_WARNING, "%s is not a valid parkingtime\n", var->value); default_parkinglot->parkingtime = DEFAULT_PARK_TIME; } else default_parkinglot->parkingtime = default_parkinglot->parkingtime * 1000; } else if (!strcasecmp(var->name, "parkpos")) { - if (sscanf(var->value, "%d-%d", &start, &end) != 2) { + if (sscanf(var->value, "%30d-%30d", &start, &end) != 2) { ast_log(LOG_WARNING, "Format for parking positions is a-b, where a and b are numbers at line %d of features.conf\n", var->lineno); } else if (default_parkinglot) { default_parkinglot->parking_start = start; @@ -3984,24 +3984,24 @@ static int load_config(void) } else if (!strcasecmp(var->name, "adsipark")) { adsipark = ast_true(var->value); } else if (!strcasecmp(var->name, "transferdigittimeout")) { - if ((sscanf(var->value, "%d", &transferdigittimeout) != 1) || (transferdigittimeout < 1)) { + if ((sscanf(var->value, "%30d", &transferdigittimeout) != 1) || (transferdigittimeout < 1)) { ast_log(LOG_WARNING, "%s is not a valid transferdigittimeout\n", var->value); transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT; } else transferdigittimeout = transferdigittimeout * 1000; } else if (!strcasecmp(var->name, "featuredigittimeout")) { - if ((sscanf(var->value, "%d", &featuredigittimeout) != 1) || (featuredigittimeout < 1)) { + if ((sscanf(var->value, "%30d", &featuredigittimeout) != 1) || (featuredigittimeout < 1)) { ast_log(LOG_WARNING, "%s is not a valid featuredigittimeout\n", var->value); featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT; } } else if (!strcasecmp(var->name, "atxfernoanswertimeout")) { - if ((sscanf(var->value, "%d", &atxfernoanswertimeout) != 1) || (atxfernoanswertimeout < 1)) { + if ((sscanf(var->value, "%30d", &atxfernoanswertimeout) != 1) || (atxfernoanswertimeout < 1)) { ast_log(LOG_WARNING, "%s is not a valid atxfernoanswertimeout\n", var->value); atxfernoanswertimeout = DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER; } else atxfernoanswertimeout = atxfernoanswertimeout * 1000; } else if (!strcasecmp(var->name, "atxferloopdelay")) { - if ((sscanf(var->value, "%u", &atxferloopdelay) != 1)) { + if ((sscanf(var->value, "%30u", &atxferloopdelay) != 1)) { ast_log(LOG_WARNING, "%s is not a valid atxferloopdelay\n", var->value); atxferloopdelay = DEFAULT_ATXFER_LOOP_DELAY; } else @@ -4009,7 +4009,7 @@ static int load_config(void) } else if (!strcasecmp(var->name, "atxferdropcall")) { atxferdropcall = ast_true(var->value); } else if (!strcasecmp(var->name, "atxfercallbackretries")) { - if ((sscanf(var->value, "%u", &atxferloopdelay) != 1)) { + if ((sscanf(var->value, "%30u", &atxferloopdelay) != 1)) { ast_log(LOG_WARNING, "%s is not a valid atxfercallbackretries\n", var->value); atxfercallbackretries = DEFAULT_ATXFER_CALLBACK_RETRIES; } @@ -4605,7 +4605,7 @@ static int manager_park(struct mansession *s, const struct message *m) } if (!ast_strlen_zero(timeout)) { - sscanf(timeout, "%d", &to); + sscanf(timeout, "%30d", &to); } res = ast_masq_park_call(ch1, ch2, to, &parkExt); diff --git a/main/frame.c b/main/frame.c index fa443407c..ea902db8c 100644 --- a/main/frame.c +++ b/main/frame.c @@ -735,7 +735,7 @@ static char *show_codec_n(struct ast_cli_entry *e, int cmd, struct ast_cli_args if (a->argc != 4) return CLI_SHOWUSAGE; - if (sscanf(a->argv[3],"%d",&codec) != 1) + if (sscanf(a->argv[3], "%30d", &codec) != 1) return CLI_SHOWUSAGE; for (i = 0; i < 32; i++) diff --git a/main/http.c b/main/http.c index a5dd568bf..ce42c4423 100644 --- a/main/http.c +++ b/main/http.c @@ -154,7 +154,7 @@ uint32_t ast_http_manid_from_vars(struct ast_variable *headers) cookies = ast_http_get_cookies(headers); for (v = cookies; v; v = v->next) { if (!strcasecmp(v->name, "mansession_id")) { - sscanf(v->value, "%x", &mngid); + sscanf(v->value, "%30x", &mngid); break; } } diff --git a/main/indications.c b/main/indications.c index f0aba5ff3..b658e3f51 100644 --- a/main/indications.c +++ b/main/indications.c @@ -243,50 +243,50 @@ static struct ast_generator playtones = { int ast_tone_zone_part_parse(const char *s, struct ast_tone_zone_part *tone_data) { - if (sscanf(s, "%u+%u/%u", &tone_data->freq1, &tone_data->freq2, + if (sscanf(s, "%30u+%30u/%30u", &tone_data->freq1, &tone_data->freq2, &tone_data->time) == 3) { /* f1+f2/time format */ - } else if (sscanf(s, "%u+%u", &tone_data->freq1, &tone_data->freq2) == 2) { + } else if (sscanf(s, "%30u+%30u", &tone_data->freq1, &tone_data->freq2) == 2) { /* f1+f2 format */ tone_data->time = 0; - } else if (sscanf(s, "%u*%u/%u", &tone_data->freq1, &tone_data->freq2, + } else if (sscanf(s, "%30u*%30u/%30u", &tone_data->freq1, &tone_data->freq2, &tone_data->time) == 3) { /* f1*f2/time format */ tone_data->modulate = 1; - } else if (sscanf(s, "%u*%u", &tone_data->freq1, &tone_data->freq2) == 2) { + } else if (sscanf(s, "%30u*%30u", &tone_data->freq1, &tone_data->freq2) == 2) { /* f1*f2 format */ tone_data->time = 0; tone_data->modulate = 1; - } else if (sscanf(s, "%u/%u", &tone_data->freq1, &tone_data->time) == 2) { + } else if (sscanf(s, "%30u/%30u", &tone_data->freq1, &tone_data->time) == 2) { /* f1/time format */ tone_data->freq2 = 0; - } else if (sscanf(s, "%u", &tone_data->freq1) == 1) { + } else if (sscanf(s, "%30u", &tone_data->freq1) == 1) { /* f1 format */ tone_data->freq2 = 0; tone_data->time = 0; - } else if (sscanf(s, "M%u+M%u/%u", &tone_data->freq1, &tone_data->freq2, + } else if (sscanf(s, "M%30u+M%30u/%30u", &tone_data->freq1, &tone_data->freq2, &tone_data->time) == 3) { /* Mf1+Mf2/time format */ tone_data->midinote = 1; - } else if (sscanf(s, "M%u+M%u", &tone_data->freq1, &tone_data->freq2) == 2) { + } else if (sscanf(s, "M%30u+M%30u", &tone_data->freq1, &tone_data->freq2) == 2) { /* Mf1+Mf2 format */ tone_data->time = 0; tone_data->midinote = 1; - } else if (sscanf(s, "M%u*M%u/%u", &tone_data->freq1, &tone_data->freq2, + } else if (sscanf(s, "M%30u*M%30u/%30u", &tone_data->freq1, &tone_data->freq2, &tone_data->time) == 3) { /* Mf1*Mf2/time format */ tone_data->modulate = 1; tone_data->midinote = 1; - } else if (sscanf(s, "M%u*M%u", &tone_data->freq1, &tone_data->freq2) == 2) { + } else if (sscanf(s, "M%30u*M%30u", &tone_data->freq1, &tone_data->freq2) == 2) { /* Mf1*Mf2 format */ tone_data->time = 0; tone_data->modulate = 1; tone_data->midinote = 1; - } else if (sscanf(s, "M%u/%u", &tone_data->freq1, &tone_data->time) == 2) { + } else if (sscanf(s, "M%30u/%30u", &tone_data->freq1, &tone_data->time) == 2) { /* Mf1/time format */ tone_data->freq2 = -1; tone_data->midinote = 1; - } else if (sscanf(s, "M%u", &tone_data->freq1) == 1) { + } else if (sscanf(s, "M%30u", &tone_data->freq1) == 1) { /* Mf1 format */ tone_data->freq2 = -1; tone_data->time = 0; diff --git a/main/manager.c b/main/manager.c index f4d9e1e6f..f6501c5e0 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2474,7 +2474,7 @@ static int action_waitevent(struct mansession *s, const struct message *m) } if (!ast_strlen_zero(timeouts)) { - sscanf(timeouts, "%i", &timeout); + sscanf(timeouts, "%30i", &timeout); if (timeout < -1) { timeout = -1; } @@ -2962,7 +2962,7 @@ static int action_redirect(struct mansession *s, const struct message *m) return 0; } - if (!ast_strlen_zero(priority) && (sscanf(priority, "%d", &pi) != 1)) { + if (!ast_strlen_zero(priority) && (sscanf(priority, "%30d", &pi) != 1)) { if ((pi = ast_findlabel_extension(NULL, context, exten, priority, NULL)) < 1) { astman_send_error(s, m, "Invalid priority"); return 0; @@ -3270,13 +3270,13 @@ static int action_originate(struct mansession *s, const struct message *m) astman_send_error(s, m, "Channel not specified"); return 0; } - if (!ast_strlen_zero(priority) && (sscanf(priority, "%d", &pi) != 1)) { + if (!ast_strlen_zero(priority) && (sscanf(priority, "%30d", &pi) != 1)) { if ((pi = ast_findlabel_extension(NULL, context, exten, priority, NULL)) < 1) { astman_send_error(s, m, "Invalid priority"); return 0; } } - if (!ast_strlen_zero(timeout) && (sscanf(timeout, "%d", &to) != 1)) { + if (!ast_strlen_zero(timeout) && (sscanf(timeout, "%30d", &to) != 1)) { astman_send_error(s, m, "Invalid timeout"); return 0; } @@ -4731,7 +4731,7 @@ static int generic_http_callback(struct ast_tcptls_session_instance *ser, cookies = ast_http_get_cookies(headers); for (v = cookies; v; v = v->next) { if (!strcasecmp(v->name, "mansession_id")) { - sscanf(v->value, "%x", &ident); + sscanf(v->value, "%30x", &ident); break; } } @@ -4988,7 +4988,7 @@ static int auth_http_callback(struct ast_tcptls_session_instance *ser, nonce = 0; goto out_401; } - if (sscanf(d.nonce, "%lx", &nonce) != 1) { + if (sscanf(d.nonce, "%30lx", &nonce) != 1) { ast_log(LOG_WARNING, "Received incorrect nonce in Digest <%s>\n", d.nonce); nonce = 0; goto out_401; @@ -5094,7 +5094,7 @@ static int auth_http_callback(struct ast_tcptls_session_instance *ser, stale = 1; goto out_401; } else { - sscanf(d.nc, "%lx", &nc); + sscanf(d.nc, "%30lx", &nc); if (session->nc >= nc || ((time_now - session->noncetime) > 62) ) { /* * Nonce time expired (> 2 minutes) or something wrong with nonce diff --git a/main/netsock.c b/main/netsock.c index 2bdf9ccd6..24c6f12b5 100644 --- a/main/netsock.c +++ b/main/netsock.c @@ -280,7 +280,7 @@ int ast_str_to_eid(struct ast_eid *eid, const char *s) unsigned int eid_int[6]; int x; - if (sscanf(s, "%x:%x:%x:%x:%x:%x", &eid_int[0], &eid_int[1], &eid_int[2], + if (sscanf(s, "%2x:%2x:%2x:%2x:%2x:%2x", &eid_int[0], &eid_int[1], &eid_int[2], &eid_int[3], &eid_int[4], &eid_int[5]) != 6) return -1; diff --git a/main/pbx.c b/main/pbx.c index 2a4ea234d..9570009ee 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -2807,7 +2807,7 @@ static int parse_variable_name(char *var, int *offset, int *length, int *isfunc) parens--; } else if (*var == ':' && parens == 0) { *var++ = '\0'; - sscanf(var, "%d:%d", offset, length); + sscanf(var, "%30d:%30d", offset, length); return 1; /* offset:length valid */ } } @@ -7079,7 +7079,7 @@ static int lookup_name(const char *s, const char * const names[], int max) } /* Allow months and weekdays to be specified as numbers, as well */ - if (sscanf(s, "%d", &i) == 1 && i >= 1 && i <= max) { + if (sscanf(s, "%2d", &i) == 1 && i >= 1 && i <= max) { /* What the array offset would have been: "1" would be at offset 0 */ return i - 1; } @@ -7155,7 +7155,7 @@ static void get_timerange(struct ast_timing *i, char *times) /* Otherwise expect a range */ while ((part = strsep(×, "&"))) { if (!(endpart = strchr(part, '-'))) { - if (sscanf(part, "%d:%d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) { + if (sscanf(part, "%2d:%2d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) { ast_log(LOG_WARNING, "%s isn't a valid time.\n", part); continue; } @@ -7171,11 +7171,11 @@ static void get_timerange(struct ast_timing *i, char *times) ast_log(LOG_WARNING, "Invalid time range starting with '%s-'.\n", part); continue; } - if (sscanf(part, "%d:%d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) { + if (sscanf(part, "%2d:%2d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) { ast_log(LOG_WARNING, "'%s' isn't a valid start time.\n", part); continue; } - if (sscanf(endpart, "%d:%d", &endh, &endm) != 2 || endh < 0 || endh > 23 || endm < 0 || endm > 59) { + if (sscanf(endpart, "%2d:%2d", &endh, &endm) != 2 || endh < 0 || endh > 23 || endm < 0 || endm > 59) { ast_log(LOG_WARNING, "'%s' isn't a valid end time.\n", endpart); continue; } @@ -8711,7 +8711,7 @@ static void wait_for_hangup(struct ast_channel *chan, const void *data) double waitsec; int waittime; - if (ast_strlen_zero(data) || (sscanf(data, "%lg", &waitsec) != 1) || (waitsec < 0)) + if (ast_strlen_zero(data) || (sscanf(data, "%30lg", &waitsec) != 1) || (waitsec < 0)) waitsec = -1; if (waitsec > -1) { waittime = waitsec * 1000.0; @@ -9465,7 +9465,7 @@ int pbx_checkcondition(const char *condition) int res; if (ast_strlen_zero(condition)) { /* NULL or empty strings are false */ return 0; - } else if (sscanf(condition, "%d", &res) == 1) { /* Numbers are evaluated for truth */ + } else if (sscanf(condition, "%30d", &res) == 1) { /* Numbers are evaluated for truth */ return res; } else { /* Strings are true */ return 1; @@ -9880,7 +9880,7 @@ static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string, mode = -1; pri++; } - if (sscanf(pri, "%d", &ipri) != 1) { + if (sscanf(pri, "%30d", &ipri) != 1) { if ((ipri = ast_findlabel_extension(chan, context ? context : chan->context, exten ? exten : chan->exten, pri, chan->cid.cid_num)) < 1) { ast_log(LOG_WARNING, "Priority '%s' must be a number > 0, or valid label\n", pri); diff --git a/main/timing.c b/main/timing.c index d0e6a6d24..ac23d42fa 100644 --- a/main/timing.c +++ b/main/timing.c @@ -229,7 +229,7 @@ static char *timing_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args * if (a->argc == 3) { unsigned int rate; - if (sscanf(a->argv[2], "%u", &rate) == 1) { + if (sscanf(a->argv[2], "%30u", &rate) == 1) { test_rate = rate; } else { ast_cli(a->fd, "Invalid rate '%s', using default of %u\n", a->argv[2], test_rate); diff --git a/main/utils.c b/main/utils.c index 4c0ff3aa8..550d927d0 100644 --- a/main/utils.c +++ b/main/utils.c @@ -1826,7 +1826,7 @@ int ast_get_timeval(const char *src, struct timeval *dst, struct timeval _defaul return -1; /* only integer at the moment, but one day we could accept more formats */ - if (sscanf(src, "%Lf%n", &dtv, &scanned) > 0) { + if (sscanf(src, "%30Lf%n", &dtv, &scanned) > 0) { dst->tv_sec = dtv; dst->tv_usec = (dtv - dst->tv_sec) * 1000000.0; if (consumed) @@ -1853,7 +1853,7 @@ int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed) return -1; /* only integer at the moment, but one day we could accept more formats */ - if (sscanf(src, "%ld%n", &t, &scanned) == 1) { + if (sscanf(src, "%30ld%n", &t, &scanned) == 1) { *dst = t; if (consumed) *consumed = scanned; @@ -2012,7 +2012,7 @@ int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, d->qop = 1; } else if (!strcasecmp(key, "nc")) { unsigned long u; - if (sscanf(val, "%lx", &u) != 1) { + if (sscanf(val, "%30lx", &u) != 1) { ast_log(LOG_WARNING, "Incorrect Digest nc value: \"%s\".\n", val); return -1; } |