Pau Espin Pedrol has uploaded this change for review. ( 
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, 3 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/79/9979/1

diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c 
b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
index af110a2..e244827 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
@@ -85,8 +85,9 @@
 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;
+       int id = (long int) strtol(id_str, &endptr, 10);
+       if (id_str[0] == '\0' || endptr[0] != '\0')
                return NULL;

        llist_for_each_entry(cmd_entry, &bsc->cmd_pending, list_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: newchange
Gerrit-Change-Id: Ief0b203efbcf2be04253b5056840be94d58a9994
Gerrit-Change-Number: 9979
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to