diff --git a/bin/sh/arith_lex.l b/bin/sh/arith_lex.l index 1113d2992970..b4a04d3fd3de 100644 --- a/bin/sh/arith_lex.l +++ b/bin/sh/arith_lex.l @@ -53,7 +53,15 @@ int yylex(void); #undef YY_INPUT #define YY_INPUT(buf,result,max) \ - result = (*buf = *arith_buf++) ? 1 : YY_NULL; + do { \ + result = strnlen(arith_buf, max); \ + if (result == 0) \ + result = YY_NULL; \ + else { \ + memcpy(buf, arith_buf, result); \ + arith_buf += result; \ + } \ + } while (0); #define YY_NO_UNPUT #define YY_NO_INPUT %}