1/*- 2 * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/teken/teken.c 286827 2015-08-16 13:59:11Z ed $ |
27 */ 28 29#include <sys/cdefs.h> 30#if defined(__FreeBSD__) && defined(_KERNEL) 31#include <sys/param.h> 32#include <sys/limits.h> 33#include <sys/lock.h> 34#include <sys/systm.h> --- 371 unchanged lines hidden (view full) --- 406 407 teken_assert(t->t_curnum < T_NUMSIZE); 408 409 if (c >= '0' && c <= '9') { 410 if (t->t_stateflags & TS_FIRSTDIGIT) { 411 /* First digit. */ 412 t->t_stateflags &= ~TS_FIRSTDIGIT; 413 t->t_nums[t->t_curnum] = c - '0'; |
414 } else if (t->t_nums[t->t_curnum] < UINT_MAX / 100) { |
415 /* |
416 * There is no need to continue parsing input 417 * once the value exceeds the size of the 418 * terminal. It would only allow for integer 419 * overflows when performing arithmetic on the 420 * cursor position. 421 * 422 * Ignore any further digits if the value is 423 * already UINT_MAX / 100. |
424 */ 425 t->t_nums[t->t_curnum] = 426 t->t_nums[t->t_curnum] * 10 + c - '0'; 427 } 428 return (1); 429 } else if (c == ';') { 430 if (t->t_stateflags & TS_FIRSTDIGIT) 431 t->t_nums[t->t_curnum] = 0; --- 135 unchanged lines hidden --- |