{
while (pos < LINELEN && isspace(linebuf[pos]) && linebuf[pos] != '\n')
pos++;
+
+ if (pos >= LINELEN)
+ {
+ diag ("line length overrun at %d.\n", pos);
+ exit (1);
+ }
+
return;
}
static inline void
safe_inc_pos (void)
{
- if (pos++ >= LINELEN)
+ if (++pos >= LINELEN)
{
(*diag) ("line length overrun.\n");
exit (1);
match_identifier (void)
{
int lastpos = pos - 1;
- while (isalnum (linebuf[lastpos + 1]) || linebuf[lastpos + 1] == '_')
+ while (lastpos < LINELEN - 1
+ && (isalnum (linebuf[lastpos + 1]) || linebuf[lastpos + 1] == '_'))
++lastpos;
+ if (lastpos >= LINELEN - 1)
+ {
+ diag ("line length overrun at %d.\n", lastpos);
+ exit (1);
+ }
+
if (lastpos < pos)
return 0;
safe_inc_pos ();
int lastpos = pos - 1;
- while (isdigit (linebuf[lastpos + 1]))
+ while (lastpos < LINELEN - 1 && isdigit (linebuf[lastpos + 1]))
++lastpos;
+ if (lastpos >= LINELEN - 1)
+ {
+ diag ("line length overrun at %d.\n", lastpos);
+ exit (1);
+ }
+
if (lastpos < pos)
return NULL;
match_to_right_bracket (void)
{
int lastpos = pos - 1;
- while (linebuf[lastpos + 1] != ']')
+ while (lastpos < LINELEN - 1 && linebuf[lastpos + 1] != ']')
{
if (linebuf[lastpos + 1] == '\n')
{
++lastpos;
}
+ if (lastpos >= LINELEN - 1)
+ {
+ diag ("line length overrun at %d.\n", lastpos);
+ exit (1);
+ }
+
if (lastpos < pos)
return 0;