aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--builtin_set.c9
-rw-r--r--expand.c8
-rw-r--r--history.c10
-rw-r--r--signal.c2
-rw-r--r--util.c20
5 files changed, 38 insertions, 11 deletions
diff --git a/builtin_set.c b/builtin_set.c
index 88e8fef9..084031ce 100644
--- a/builtin_set.c
+++ b/builtin_set.c
@@ -232,9 +232,14 @@ static int parse_index( array_list_t *indexes,
while (*src != L']')
{
wchar_t *end;
- long l_ind = wcstol(src, &end, 10);
- if (end == src)
+ long l_ind;
+
+ errno = 0;
+
+ l_ind = wcstol(src, &end, 10);
+
+ if( end==src || errno )
{
sb_printf(sb_err, _(L"%ls: Invalid index starting at '%ls'\n"), L"set", src);
return 0;
diff --git a/expand.c b/expand.c
index a49b5336..f0a973fd 100644
--- a/expand.c
+++ b/expand.c
@@ -387,8 +387,12 @@ static int find_process( const wchar_t *proc,
else
{
- int jid = wcstol( proc, 0, 10 );
- if( jid > 0 )
+ int jid;
+ wchar_t *end;
+
+ errno = 0;
+ jid = wcstol( proc, &end, 10 );
+ if( jid > 0 && !errno && !*end )
{
j = job_get( jid );
if( (j != 0) && (j->command != 0 ) )
diff --git a/history.c b/history.c
index 36cd54c1..33b7f836 100644
--- a/history.c
+++ b/history.c
@@ -345,9 +345,13 @@ static item_t *item_get( history_mode_t *m, void *d )
if( *time_string )
{
- time_t tm = (time_t)wcstol( time_string, 0, 10 );
-
- if( tm && !errno )
+ time_t tm;
+ wchar_t *end;
+
+ errno = 0;
+ tm = (time_t)wcstol( time_string, &end, 10 );
+
+ if( tm && !errno && !*end )
{
narrow_item.timestamp = tm;
}
diff --git a/signal.c b/signal.c
index e18c5cdc..3109e3ee 100644
--- a/signal.c
+++ b/signal.c
@@ -385,7 +385,7 @@ int wcs2sig( const wchar_t *str )
}
errno=0;
res = wcstol( str, &end, 10 );
- if( !errno && end && !*end )
+ if( !errno && res>=0 && !*end )
return res;
return -1;
diff --git a/util.c b/util.c
index f6de95ca..e709ce4d 100644
--- a/util.c
+++ b/util.c
@@ -1112,9 +1112,23 @@ int wcsfilecmp( const wchar_t *a, const wchar_t *b )
if( iswdigit( *a ) && iswdigit( *b ) )
{
wchar_t *aend, *bend;
- long al = wcstol( a, &aend, 10 );
- long bl = wcstol( b, &bend, 10 );
- int diff = al - bl;
+ long al;
+ long bl;
+ int diff;
+
+ errno = 0;
+ al = wcstol( a, &aend, 10 );
+ bl = wcstol( b, &bend, 10 );
+
+ if( errno )
+ {
+ /*
+ Huuuuuuuuge numbers - fall back to regular string comparison
+ */
+ return wcscmp( a, b );
+ }
+
+ diff = al - bl;
if( diff )
return diff>0?2:-2;