Initial commit
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Build Kernel / Build all affected Kernels (push) Has been cancelled
				
			
		
			
				
	
				Build all core packages / Build all core packages for selected target (push) Has been cancelled
				
			
		
			
				
	
				Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
				
			
		
			
				
	
				Build Toolchains / Build Toolchains for each target (push) Has been cancelled
				
			
		
			
				
	
				Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
				
			
		
			
				
	
				Coverity scan build / Coverity x86/64 build (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Build Kernel / Build all affected Kernels (push) Has been cancelled
				
			Build all core packages / Build all core packages for selected target (push) Has been cancelled
				
			Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
				
			Build Toolchains / Build Toolchains for each target (push) Has been cancelled
				
			Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
				
			Coverity scan build / Coverity x86/64 build (push) Has been cancelled
				
			This commit is contained in:
		| @@ -0,0 +1,41 @@ | ||||
| --- a/src/lnum.c | ||||
| +++ b/src/lnum.c | ||||
| @@ -127,6 +127,8 @@ static int luaO_str2i (const char *s, lu | ||||
|  #else | ||||
|        return 0;  /* Reject the number */ | ||||
|  #endif | ||||
| +    } else if (v > LUA_INTEGER_MAX) { | ||||
| +      return TK_NUMBER; | ||||
|      } | ||||
|    } else if ((v > LUA_INTEGER_MAX) || (*endptr && (!isspace(*endptr)))) { | ||||
|      return TK_NUMBER;	/* not in signed range, or has '.', 'e' etc. trailing */ | ||||
| @@ -310,3 +312,13 @@ int try_unmint( lua_Integer *r, lua_Inte | ||||
|    return 0; | ||||
|  } | ||||
|   | ||||
| +#ifdef LONG_OVERFLOW_LUA_INTEGER | ||||
| +unsigned LUA_INTEGER lua_str2ul( const char *str, char **endptr, int base ) { | ||||
| +  unsigned long v= strtoul(str, endptr, base); | ||||
| +  if ( v > LUA_INTEGER_MAX ) { | ||||
| +    errno= ERANGE; | ||||
| +    v= ULONG_MAX; | ||||
| +  } | ||||
| +  return (unsigned LUA_INTEGER)v; | ||||
| +} | ||||
| +#endif | ||||
| --- a/src/lnum_config.h | ||||
| +++ b/src/lnum_config.h | ||||
| @@ -141,7 +141,12 @@ | ||||
|  #endif | ||||
|   | ||||
|  #ifndef lua_str2ul | ||||
| -# define lua_str2ul (unsigned LUA_INTEGER)strtoul | ||||
| +# if LONG_MAX > LUA_INTEGER_MAX | ||||
| +#   define LONG_OVERFLOW_LUA_INTEGER | ||||
| +    unsigned LUA_INTEGER lua_str2ul( const char *str, char **endptr, int base ); | ||||
| +# else | ||||
| +#  define lua_str2ul (unsigned LUA_INTEGER)strtoul | ||||
| +# endif | ||||
|  #endif | ||||
|  #ifndef LUA_INTEGER_MIN | ||||
|  # define LUA_INTEGER_MIN (-LUA_INTEGER_MAX -1)  /* -2^16|32 */ | ||||
		Reference in New Issue
	
	Block a user
	 domenico
					domenico