summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/glob.h14
-rw-r--r--lib/libc/gen/glob.316
-rw-r--r--lib/libc/gen/glob.c33
-rw-r--r--lib/libc/shlib_version2
4 files changed, 35 insertions, 30 deletions
diff --git a/include/glob.h b/include/glob.h
index 92d06e60f3c..6e64bca2b42 100644
--- a/include/glob.h
+++ b/include/glob.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: glob.h,v 1.13 2012/12/05 23:19:57 deraadt Exp $ */
+/* $OpenBSD: glob.h,v 1.14 2019/02/04 16:45:40 millert Exp $ */
/* $NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $ */
/*
@@ -39,12 +39,18 @@
#define _GLOB_H_
#include <sys/stat.h>
+#include <machine/_types.h>
+
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
struct stat;
typedef struct {
- int gl_pathc; /* Count of total paths so far. */
- int gl_matchc; /* Count of paths matching pattern. */
- int gl_offs; /* Reserved at beginning of gl_pathv. */
+ size_t gl_pathc; /* Count of total paths so far. */
+ size_t gl_matchc; /* Count of paths matching pattern. */
+ size_t gl_offs; /* Reserved at beginning of gl_pathv. */
int gl_flags; /* Copy of flags parameter to glob. */
char **gl_pathv; /* List of paths matching pattern. */
struct stat **gl_statv; /* Stat entries corresponding to gl_pathv */
diff --git a/lib/libc/gen/glob.3 b/lib/libc/gen/glob.3
index 016324254b6..0d3aaed8835 100644
--- a/lib/libc/gen/glob.3
+++ b/lib/libc/gen/glob.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: glob.3,v 1.35 2017/07/06 15:42:04 schwarze Exp $
+.\" $OpenBSD: glob.3,v 1.36 2019/02/04 16:45:40 millert Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: July 6 2017 $
+.Dd $Mdocdate: February 4 2019 $
.Dt GLOB 3
.Os
.Sh NAME
@@ -53,13 +53,13 @@ The include file
defines the structure type
.Li glob_t ,
which contains at least the following fields:
-.Bd -literal -offset indent
+.Bd -literal
typedef struct {
- int gl_pathc; /* count of total paths so far */
- int gl_matchc; /* count of paths matching pattern */
- int gl_offs; /* reserved at beginning of gl_pathv */
- int gl_flags; /* returned flags */
- char **gl_pathv; /* list of paths matching pattern */
+ size_t gl_pathc; /* count of total paths so far */
+ size_t gl_matchc; /* count of paths matching pattern */
+ size_t gl_offs; /* reserved at beginning of gl_pathv */
+ int gl_flags; /* returned flags */
+ char **gl_pathv; /* list of paths matching pattern */
} glob_t;
.Ed
.Pp
diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c
index dafae849196..8b69031d54f 100644
--- a/lib/libc/gen/glob.c
+++ b/lib/libc/gen/glob.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: glob.c,v 1.47 2017/05/08 14:53:27 millert Exp $ */
+/* $OpenBSD: glob.c,v 1.48 2019/02/04 16:45:40 millert Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -139,7 +139,7 @@ struct glob_path_stat {
static int compare(const void *, const void *);
static int compare_gps(const void *, const void *);
-static int g_Ctoc(const Char *, char *, u_int);
+static int g_Ctoc(const Char *, char *, size_t);
static int g_lstat(Char *, struct stat *, glob_t *);
static DIR *g_opendir(Char *, glob_t *);
static Char *g_strchr(const Char *, int);
@@ -187,9 +187,8 @@ glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
if (strnlen(pattern, PATH_MAX) == PATH_MAX)
return(GLOB_NOMATCH);
- if (pglob->gl_offs < 0 || pglob->gl_pathc < 0 ||
- pglob->gl_offs >= INT_MAX || pglob->gl_pathc >= INT_MAX ||
- pglob->gl_pathc >= INT_MAX - pglob->gl_offs - 1)
+ if (pglob->gl_offs >= SSIZE_MAX || pglob->gl_pathc >= SSIZE_MAX ||
+ pglob->gl_pathc >= SSIZE_MAX - pglob->gl_offs - 1)
return GLOB_NOSPACE;
bufnext = patbuf;
@@ -462,7 +461,8 @@ static int
glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
{
const Char *qpatnext;
- int c, err, oldpathc;
+ int c, err;
+ size_t oldpathc;
Char *bufnext, patbuf[PATH_MAX];
qpatnext = globtilde(pattern, patbuf, PATH_MAX, pglob);
@@ -556,9 +556,9 @@ glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
if ((pglob->gl_flags & GLOB_KEEPSTAT)) {
/* Keep the paths and stat info synced during sort */
struct glob_path_stat *path_stat;
- int i;
- int n = pglob->gl_pathc - oldpathc;
- int o = pglob->gl_offs + oldpathc;
+ size_t i;
+ size_t n = pglob->gl_pathc - oldpathc;
+ size_t o = pglob->gl_offs + oldpathc;
if ((path_stat = calloc(n, sizeof(*path_stat))) == NULL)
return GLOB_NOSPACE;
@@ -787,20 +787,19 @@ globextend(const Char *path, glob_t *pglob, struct glob_lim *limitp,
struct stat *sb)
{
char **pathv;
- ssize_t i;
- size_t newn, len;
+ size_t i, newn, len;
char *copy = NULL;
const Char *p;
struct stat **statv;
newn = 2 + pglob->gl_pathc + pglob->gl_offs;
- if (pglob->gl_offs >= INT_MAX ||
- pglob->gl_pathc >= INT_MAX ||
- newn >= INT_MAX ||
+ if (pglob->gl_offs >= SSIZE_MAX ||
+ pglob->gl_pathc >= SSIZE_MAX ||
+ newn >= SSIZE_MAX ||
SIZE_MAX / sizeof(*pathv) <= newn ||
SIZE_MAX / sizeof(*statv) <= newn) {
nospace:
- for (i = pglob->gl_offs; i < (ssize_t)(newn - 2); i++) {
+ for (i = pglob->gl_offs; i < newn - 2; i++) {
if (pglob->gl_pathv && pglob->gl_pathv[i])
free(pglob->gl_pathv[i]);
if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0 &&
@@ -961,7 +960,7 @@ fail:
void
globfree(glob_t *pglob)
{
- int i;
+ size_t i;
char **pp;
if (pglob->gl_pathv != NULL) {
@@ -1033,7 +1032,7 @@ g_strchr(const Char *str, int ch)
}
static int
-g_Ctoc(const Char *str, char *buf, u_int len)
+g_Ctoc(const Char *str, char *buf, size_t len)
{
while (len--) {
diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version
index 450ffe9bf59..2f0e8523115 100644
--- a/lib/libc/shlib_version
+++ b/lib/libc/shlib_version
@@ -1,4 +1,4 @@
-major=94
+major=95
minor=0
# note: If changes were made to include/thread_private.h or if system
# calls were added/changed then librthread/shlib_version also be updated.