Skip to content

Commit 1797280

Browse files
committed
sd-bus: make sure %m resolves to the specified error in bus_error_set_errnofv()
1 parent 818eae4 commit 1797280

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libsystemd/sd-bus/bus-error.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ _public_ int sd_bus_error_set_errno(sd_bus_error *e, int error) {
444444
}
445445

446446
int bus_error_set_errnofv(sd_bus_error *e, int error, const char *format, va_list ap) {
447+
PROTECT_ERRNO;
447448
int r;
448449

449450
if (error < 0)
@@ -477,8 +478,9 @@ int bus_error_set_errnofv(sd_bus_error *e, int error, const char *format, va_lis
477478
if (format) {
478479
char *m;
479480

480-
/* First, let's try to fill in the supplied message */
481+
/* Then, let's try to fill in the supplied message */
481482

483+
errno = error; /* Make sure that %m resolves to the specified error */
482484
r = vasprintf(&m, format, ap);
483485
if (r >= 0) {
484486

0 commit comments

Comments
 (0)