--- catdoc-deb/catdoc-0.95/src/xlsparse.c	2026-11-11 11:27:17.092439721 +0800
+++ catdoc-fix2/src/xlsparse.c	2026-11-11 17:22:34.941472707 +0800
@@ -307,6 +307,7 @@
 		int row,col,format_code;
 		unsigned char **pcell;
 
+		if (reclen < 10) break;
 		saved_reference=NULL;
 		row = getshort(rec,0)-startrow; 
 		col = getshort(rec,2);
@@ -324,6 +325,7 @@
 		saved_reference=NULL;
 
 		for (offset=4,col=startcol;col<=endcol;offset+=6,col++) { 
+			if (offset + 10 > (int) reclen) break;
 			pcell=allocate(row,col);
 			format_code=getshort(rec,offset);
 			*pcell=(unsigned char *)strdup(format_rk(rec+offset+2,format_code));
@@ -617,7 +619,7 @@
  	/*fprintf(stderr,"Format idx %x to be set to dirty\n",format_code);
 	 */
 	dateindex=BuiltInDateFormatIdx(format_code);
-	if (dateindex) {
+	if (dateindex > 0 && dateindex < NUMOFDATEFORMATS) {
 	  FormatIdxUsed[dateindex]=1;
  	  /*fprintf(stderr,"Date idx %d is set to be dirty\n",dateindex); */
 	}
