@@ -3246,6 +3246,7 @@ static int maintain_version(char *file, int forcep)
32463246 * is versioned one higher than the existing highest version.
32473247 */
32483248 FindHighestVersion (VA .files , entry , max_no );
3249+ if (max_no >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
32493250 sprintf (ver , "%u" , max_no + 1 );
32503251/*
32513252 * The old file should have the same case name as the versionless
@@ -3570,6 +3571,7 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile)
35703571 * link missing versionless file.
35713572 */
35723573 FindHighestVersion (varray , entry , max_no );
3574+ if (max_no >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
35733575 sprintf (vbuf , "%u" , max_no + 1 );
35743576 ConcNameAndVersion (vless , vbuf , vfile );
35753577 strcpy (afile , vless );
@@ -3578,6 +3580,7 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile)
35783580 /* A version is specified. */
35793581 ver_no = strtoul (ver , (char * * )NULL , 10 );
35803582 FindHighestVersion (varray , entry , max_no );
3583+ if (max_no >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
35813584 if (ver_no == max_no + 1 ) {
35823585 /*
35833586 * If the version is one higher than the
@@ -3926,6 +3929,7 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile)
39263929 * the existing highest version.
39273930 */
39283931 FindHighestVersion (varray , entry , max_no );
3932+ if (max_no + 1 >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
39293933 sprintf (vbuf , "%u" , max_no + 1 );
39303934 /*
39313935 * We will use the file name of the existing highest
@@ -4018,6 +4022,7 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile)
40184022 * missing versionless file.
40194023 */
40204024 FindHighestVersion (varray , entry , max_no );
4025+ if (max_no + 1 >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
40214026 sprintf (vbuf , "%u" , max_no + 2 );
40224027 ConcNameAndVersion (vless , vbuf , vfile );
40234028 strcpy (afile , vfile );
@@ -4081,6 +4086,7 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile)
40814086 * new file.
40824087 */
40834088 FindHighestVersion (varray , entry , max_no );
4089+ if (max_no >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
40844090 sprintf (vbuf , "%u" , max_no + 1 );
40854091 /*
40864092 * We will use the name of the highest versioned file
@@ -4297,6 +4303,7 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile)
42974303 * link missing versionless file.
42984304 */
42994305 FindHighestVersion (varray , entry , max_no );
4306+ if (max_no >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
43004307 sprintf (vbuf , "%u" , max_no + 1 );
43014308 ConcNameAndVersion (vless , vbuf , vfile );
43024309 strcpy (afile , vless );
0 commit comments