diff --git a/src/kernel/build.c b/src/kernel/build.c index 4e3dc4721..33adaccbf 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -179,7 +179,8 @@ int destroy_cmd(unit * u, struct order *ord) s = gettoken(token, sizeof(token)); if (s && *s) { - n = atoi((const char *)s); + n = atoi10((const char *)s); + if (n <= 0) { n = INT_MAX; } diff --git a/src/util/base36.c b/src/util/base36.c index 3b5543e88..e68fd76f6 100644 --- a/src/util/base36.c +++ b/src/util/base36.c @@ -23,6 +23,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include + +int atoi10(const char *str) +{ + int i = atoi(str); + errno = 0; + return i; +} int atoi36(const char *str) { diff --git a/src/util/base36.h b/src/util/base36.h index 05c81d2c0..33f0d2f08 100644 --- a/src/util/base36.h +++ b/src/util/base36.h @@ -31,6 +31,7 @@ extern "C" { const char *itoa36(int i); const char *itoa10(int i); extern int atoi36(const char *s); + extern int atoi10(const char *s); int i10toi36(int i); #ifdef __cplusplus