Skip to content

Commit

Permalink
osix: fix bug in cut POSIX tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalak committed Dec 1, 2024
1 parent ed7019b commit 57ddb12
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bld/posix/src/cut/cut.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <limits.h>
#include "bool.h"
#include "misc.h"
#include "getopt.h"
Expand Down Expand Up @@ -160,10 +161,10 @@ static int parseList( char *list, node *head )
char *p, *op, *arg;
int low, high;

for( op = list; op != NULL; op = p + 1 ) {
for( op = list; op != NULL; op = p ) {
p = strchr( op, ',' );
if( p != NULL ) {
*p = '\0';
*p++ = '\0';
}

arg = strchr( op, '-' );
Expand All @@ -175,7 +176,11 @@ static int parseList( char *list, node *head )
}

low = atoi( op );
high = atoi( arg );
if( *arg == '\0' ) {
high = INT_MAX;
} else {
high = atoi( arg );
}

if( high < low || low == 0 ) { // There was a range error.
return( 1 );
Expand Down

0 comments on commit 57ddb12

Please sign in to comment.