Fix buffer over-read in port encoding scan.
authorJulian Graham <julian.graham@aya.yale.edu>
Fri, 12 Nov 2010 13:45:09 +0000 (08:45 -0500)
committerJulian Graham <julian.graham@aya.yale.edu>
Fri, 12 Nov 2010 13:45:09 +0000 (08:45 -0500)
* libguile/read.c (scm_i_scan_for_encoding): Add a NULL terminator to the
  end of header to prevent over-read by subsequent call to strstr.

libguile/read.c

index 609285c..07a4ffd 100644 (file)
@@ -1646,6 +1646,7 @@ scm_i_scan_for_encoding (SCM port)
     return NULL;
 
   bytes_read = scm_c_read (port, header, SCM_ENCODING_SEARCH_SIZE);
+  header[bytes_read] = NULL;
 
   scm_seek (port, scm_from_int (0), scm_from_int (SEEK_SET));