This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Pau Espin Pedrol gerrit-no-reply at lists.osmocom.orgPau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/9979 ) Change subject: nat: ctrl: use strtol instead of atoi as it has explicit error documentation ...................................................................... nat: ctrl: use strtol instead of atoi as it has explicit error documentation In some cases id can be non-digit such as "err" for ERROR cmds generated from parsing failures. Change-Id: Ief0b203efbcf2be04253b5056840be94d58a9994 --- M openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c 1 file changed, 13 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified Harald Welte: Looks good to me, but someone else must approve Pau Espin Pedrol: Looks good to me, approved diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c index af110a2..7a5e9d0 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c @@ -36,6 +36,7 @@ #include <unistd.h> #include <string.h> #include <errno.h> +#include <limits.h> #define NAT_MAX_CTRL_ID 65535 @@ -85,10 +86,20 @@ static struct bsc_cmd_list *bsc_get_pending(struct bsc_connection *bsc, char *id_str) { struct bsc_cmd_list *cmd_entry; - int id = atoi(id_str); - if (id == 0) + char * endptr = NULL; + long int long_id; + int id; + + errno = 0; + long_id = (int) strtol(id_str, &endptr, 10); + /* check parse errors */ + if (id_str[0] == '\0' || endptr[0] != '\0') + return NULL; + /* check value store errors */ + if (errno == ERANGE || long_id > INT_MAX || long_id < 0) return NULL; + id = (int) long_id; llist_for_each_entry(cmd_entry, &bsc->cmd_pending, list_entry) { if (cmd_entry->nat_id == id) { return cmd_entry; -- To view, visit https://gerrit.osmocom.org/9979 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Ief0b203efbcf2be04253b5056840be94d58a9994 Gerrit-Change-Number: 9979 Gerrit-PatchSet: 3 Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180717/788f13fb/attachment.htm>