File tree Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Original file line number Diff line number Diff line change 11# Changes in HTMLDOC v1.9.19
22
3+ - Security: Fixed an issue with the ` file_basename ` implementation (Issue #532 )
34- Updated HTML and header/footer code to use a string pool to simplify memory
45 management and fix potential double-free bugs.
56- Updated configure script to look for zlib with pkg-config (Issue #519 )
Original file line number Diff line number Diff line change 11/*
22 * Filename routines for HTMLDOC, a HTML document processing program.
33 *
4- * Copyright © 2011-2023 by Michael R Sweet.
4+ * Copyright © 2011-2024 by Michael R Sweet.
55 * Copyright © 1997-2010 by Easy Software Products. All rights reserved.
66 *
77 * This program is free software. Distribution and use rights are outlined in
@@ -89,23 +89,23 @@ file_basename(const char *s) /* I - Filename or URL */
8989 if (s == NULL )
9090 return (NULL );
9191
92- if ((basename = strrchr (s , '/' )) != NULL )
93- basename ++ ;
94- else if ((basename = strrchr (s , '\\' )) != NULL )
95- basename ++ ;
96- else
97- basename = (char * )s ;
98-
99- if (basename [0 ] == '#' )
100- return (NULL );
92+ if (strchr (s , '#' ) != NULL )
93+ {
94+ char * bufptr ; // Pointer into buffer
10195
102- if ( strchr ( basename , '#' ) == NULL )
103- return ( basename ) ;
96+ strlcpy ( buf , s , sizeof ( buf ));
97+ s = buf ;
10498
105- strlcpy (buf , basename , sizeof (buf ));
106- * (char * )strchr (buf , '#' ) = '\0' ;
99+ if ((bufptr = strchr (buf , '#' )) != NULL )
100+ * bufptr = '\0' ;
101+ }
107102
108- return (buf );
103+ if ((basename = strrchr (s , '/' )) != NULL )
104+ return (basename + 1 );
105+ else if ((basename = strrchr (s , '\\' )) != NULL )
106+ return (basename + 1 );
107+ else
108+ return (s );
109109}
110110
111111
You can’t perform that action at this time.
0 commit comments