scanner.c: fix off by one error.

From cppcheck:
  [src/scanner.c:144]: (error) Array 'buf[1024]' accessed at index 1024, which is out of bounds.