mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-11 09:50:12 +00:00
Reviewed by: Bruce Evans <bde@freebsd.org>
Guard against possible buffer overrun in filename passed. Another candidate for 2.2.
This commit is contained in:
parent
21bef06373
commit
d53ec6c0d0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=22736
@ -47,6 +47,7 @@ static char sccsid[] = "@(#)ndbm.c 8.4 (Berkeley) 7/21/94";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <ndbm.h>
|
||||
#include "hash.h"
|
||||
@ -70,6 +71,11 @@ dbm_open(file, flags, mode)
|
||||
info.cachesize = 0;
|
||||
info.hash = NULL;
|
||||
info.lorder = 0;
|
||||
|
||||
if( strlen(file) >= sizeof(path) - strlen(DBM_SUFFIX)) {
|
||||
errno = ENAMETOOLONG;
|
||||
return(NULL);
|
||||
}
|
||||
(void)strcpy(path, file);
|
||||
(void)strcat(path, DBM_SUFFIX);
|
||||
return ((DBM *)__hash_open(path, flags, mode, &info, 0));
|
||||
|
Loading…
Reference in New Issue
Block a user