@@ -3243,6 +3243,7 @@ static int maintain_version(char *file, int forcep)
32433243 * is versioned one higher than the existing highest version.
32443244 */
32453245 FindHighestVersion (VA .files , entry , max_no );
3246+ if (max_no >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
32463247 sprintf (ver , "%u" , max_no + 1 );
32473248/*
32483249 * The old file should have the same case name as the versionless
@@ -3567,6 +3568,7 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile)
35673568 * link missing versionless file.
35683569 */
35693570 FindHighestVersion (varray , entry , max_no );
3571+ if (max_no >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
35703572 sprintf (vbuf , "%u" , max_no + 1 );
35713573 ConcNameAndVersion (vless , vbuf , vfile );
35723574 strcpy (afile , vless );
@@ -3575,6 +3577,7 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile)
35753577 /* A version is specified. */
35763578 ver_no = strtoul (ver , (char * * )NULL , 10 );
35773579 FindHighestVersion (varray , entry , max_no );
3580+ if (max_no >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
35783581 if (ver_no == max_no + 1 ) {
35793582 /*
35803583 * If the version is one higher than the
@@ -3923,6 +3926,7 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile)
39233926 * the existing highest version.
39243927 */
39253928 FindHighestVersion (varray , entry , max_no );
3929+ if (max_no + 1 >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
39263930 sprintf (vbuf , "%u" , max_no + 1 );
39273931 /*
39283932 * We will use the file name of the existing highest
@@ -4015,6 +4019,7 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile)
40154019 * missing versionless file.
40164020 */
40174021 FindHighestVersion (varray , entry , max_no );
4022+ if (max_no + 1 >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
40184023 sprintf (vbuf , "%u" , max_no + 2 );
40194024 ConcNameAndVersion (vless , vbuf , vfile );
40204025 strcpy (afile , vfile );
@@ -4078,6 +4083,7 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile)
40784083 * new file.
40794084 */
40804085 FindHighestVersion (varray , entry , max_no );
4086+ if (max_no >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
40814087 sprintf (vbuf , "%u" , max_no + 1 );
40824088 /*
40834089 * We will use the name of the highest versioned file
@@ -4294,6 +4300,7 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile)
42944300 * link missing versionless file.
42954301 */
42964302 FindHighestVersion (varray , entry , max_no );
4303+ if (max_no >= MAXVERSION ) {* Lisp_errno = EIO ; return (0 );}
42974304 sprintf (vbuf , "%u" , max_no + 1 );
42984305 ConcNameAndVersion (vless , vbuf , vfile );
42994306 strcpy (afile , vless );
0 commit comments