Skip to content

Commit c895f02

Browse files
authored
Merge branch 'openzfs:master' into idmap_userns
2 parents ff75ffb + b37d495 commit c895f02

File tree

24 files changed

+183
-91
lines changed

24 files changed

+183
-91
lines changed

cmd/zdb/zdb.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2858,9 +2858,11 @@ dump_bookmarks(objset_t *os, int verbosity)
28582858
zap_cursor_advance(&zc)) {
28592859
char osname[ZFS_MAX_DATASET_NAME_LEN];
28602860
char buf[ZFS_MAX_DATASET_NAME_LEN];
2861+
int len;
28612862
dmu_objset_name(os, osname);
2862-
VERIFY3S(0, <=, snprintf(buf, sizeof (buf), "%s#%s", osname,
2863-
attr.za_name));
2863+
len = snprintf(buf, sizeof (buf), "%s#%s", osname,
2864+
attr.za_name);
2865+
VERIFY3S(len, <, ZFS_MAX_DATASET_NAME_LEN);
28642866
(void) dump_bookmark(dp, buf, verbosity >= 5, verbosity >= 6);
28652867
}
28662868
zap_cursor_fini(&zc);

cmd/zed/zed_event.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,12 @@ _bump_event_queue_length(void)
139139
if (qlen == orig_qlen)
140140
goto done;
141141
wr = snprintf(qlen_buf, sizeof (qlen_buf), "%ld", qlen);
142+
if (wr >= sizeof (qlen_buf)) {
143+
wr = sizeof (qlen_buf) - 1;
144+
zed_log_msg(LOG_WARNING, "Truncation in %s()", __func__);
145+
}
142146

143-
if (pwrite(zzlm, qlen_buf, wr, 0) < 0)
147+
if (pwrite(zzlm, qlen_buf, wr + 1, 0) < 0)
144148
goto done;
145149

146150
zed_log_msg(LOG_WARNING, "Bumping queue length to %ld", qlen);

include/os/freebsd/spl/sys/debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
131131
const int64_t _verify3_right = (int64_t)(RIGHT); \
132132
if (unlikely(!(_verify3_left == _verify3_right))) \
133133
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
134-
"VERIFY3(0 == " #RIGHT ") " \
134+
"VERIFY0(0 == " #RIGHT ") " \
135135
"failed (0 == %lld)\n", \
136136
(long long) (_verify3_right)); \
137137
} while (0)

include/os/freebsd/spl/sys/kmem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ extern char *kmem_asprintf(const char *, ...)
5757
extern char *kmem_vasprintf(const char *fmt, va_list ap)
5858
__attribute__((format(printf, 1, 0)));
5959

60+
extern int kmem_scnprintf(char *restrict str, size_t size,
61+
const char *restrict fmt, ...);
62+
6063
typedef struct kmem_cache {
6164
char kc_name[32];
6265
#if !defined(KMEM_DEBUG)

include/os/linux/spl/sys/debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
135135
const int64_t _verify3_right = (int64_t)(RIGHT); \
136136
if (unlikely(!(_verify3_left == _verify3_right))) \
137137
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
138-
"VERIFY3(0 == " #RIGHT ") " \
138+
"VERIFY0(0 == " #RIGHT ") " \
139139
"failed (0 == %lld)\n", \
140140
(long long) (_verify3_right)); \
141141
} while (0)

include/os/linux/spl/sys/kmem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ extern char *kmem_asprintf(const char *fmt, ...)
3838
extern char *kmem_strdup(const char *str);
3939
extern void kmem_strfree(char *str);
4040

41+
#define kmem_scnprintf scnprintf
42+
4143
/*
4244
* Memory allocation interfaces
4345
*/

include/sys/spa.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ typedef struct blkptr {
600600

601601
/*
602602
* This macro allows code sharing between zfs, libzpool, and mdb.
603-
* 'func' is either snprintf() or mdb_snprintf().
603+
* 'func' is either kmem_scnprintf() or mdb_snprintf().
604604
* 'ws' (whitespace) can be ' ' for single-line format, '\n' for multi-line.
605605
*/
606606

include/sys/zfs_context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ extern char *kmem_asprintf(const char *fmt, ...);
695695
#define kmem_strfree(str) kmem_free((str), strlen(str) + 1)
696696
#define kmem_strdup(s) strdup(s)
697697

698+
extern int kmem_scnprintf(char *restrict str, size_t size,
699+
const char *restrict fmt, ...);
700+
698701
/*
699702
* Hostname information
700703
*/

lib/libshare/os/linux/smb.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,32 @@ smb_retrieve_shares(void)
9090

9191
/* Go through the directory, looking for shares */
9292
while ((directory = readdir(shares_dir))) {
93+
int fd;
94+
9395
if (directory->d_name[0] == '.')
9496
continue;
9597

9698
snprintf(file_path, sizeof (file_path),
9799
"%s/%s", SHARE_DIR, directory->d_name);
98100

101+
if ((fd = open(file_path, O_RDONLY | O_CLOEXEC)) == -1) {
102+
rc = SA_SYSTEM_ERR;
103+
goto out;
104+
}
105+
99106
if (stat(file_path, &eStat) == -1) {
107+
close(fd);
100108
rc = SA_SYSTEM_ERR;
101109
goto out;
102110
}
103111

104-
if (!S_ISREG(eStat.st_mode))
112+
if (!S_ISREG(eStat.st_mode)) {
113+
close(fd);
105114
continue;
115+
}
106116

107-
if ((share_file_fp = fopen(file_path, "re")) == NULL) {
117+
if ((share_file_fp = fdopen(fd, "r")) == NULL) {
118+
close(fd);
108119
rc = SA_SYSTEM_ERR;
109120
goto out;
110121
}

lib/libspl/os/linux/zone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ getzoneid(void)
4141

4242
int c = snprintf(path, sizeof (path), "/proc/self/ns/user");
4343
/* This API doesn't have any error checking... */
44-
if (c < 0)
44+
if (c < 0 || c >= sizeof (path))
4545
return (0);
4646

4747
ssize_t r = readlink(path, buf, sizeof (buf) - 1);

0 commit comments

Comments
 (0)