systemd: merge branch systemd into master

This commit is contained in:
Thomas Haller 2016-09-27 13:29:38 +02:00
commit 3f4aa48d6b
6 changed files with 17 additions and 14 deletions

View file

@ -1047,7 +1047,7 @@ int fopen_temporary(const char *path, FILE **_f, char **_temp_path) {
if (r < 0)
return r;
fd = mkostemp_safe(t, O_WRONLY|O_CLOEXEC);
fd = mkostemp_safe(t);
if (fd < 0) {
free(t);
return -errno;
@ -1080,7 +1080,7 @@ int fflush_and_check(FILE *f) {
}
/* This is much like mkostemp() but is subject to umask(). */
int mkostemp_safe(char *pattern, int flags) {
int mkostemp_safe(char *pattern) {
_cleanup_umask_ mode_t u = 0;
int fd;
@ -1088,7 +1088,7 @@ int mkostemp_safe(char *pattern, int flags) {
u = umask(077);
fd = mkostemp(pattern, flags);
fd = mkostemp(pattern, O_CLOEXEC);
if (fd < 0)
return -errno;
@ -1296,7 +1296,7 @@ int open_tmpfile_unlinkable(const char *directory, int flags) {
/* Fall back to unguessable name + unlinking */
p = strjoina(directory, "/systemd-tmp-XXXXXX");
fd = mkostemp_safe(p, flags);
fd = mkostemp_safe(p);
if (fd < 0)
return fd;

View file

@ -71,7 +71,7 @@ int search_and_fopen_nulstr(const char *path, const char *mode, const char *root
int fflush_and_check(FILE *f);
int fopen_temporary(const char *path, FILE **_f, char **_temp_path);
int mkostemp_safe(char *pattern, int flags);
int mkostemp_safe(char *pattern);
int tempfn_xxxxxx(const char *p, const char *extra, char **ret);
int tempfn_random(const char *p, const char *extra, char **ret);

View file

@ -446,7 +446,7 @@ static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le
if (old_length <= 3 || old_length <= new_length)
return strndup(s, old_length);
r = new0(char, new_length+1);
r = new0(char, new_length+3);
if (!r)
return NULL;
@ -456,12 +456,12 @@ static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le
x = new_length - 3;
memcpy(r, s, x);
r[x] = '.';
r[x+1] = '.';
r[x+2] = '.';
r[x] = 0xe2; /* tri-dot ellipsis: … */
r[x+1] = 0x80;
r[x+2] = 0xa6;
memcpy(r + x + 3,
s + old_length - (new_length - x - 3),
new_length - x - 3);
s + old_length - (new_length - x - 1),
new_length - x - 1);
return r;
}

View file

@ -42,8 +42,6 @@
#include "strv.h"
#include "time-util.h"
static nsec_t timespec_load_nsec(const struct timespec *ts);
static clockid_t map_clock_id(clockid_t c) {
/* Some more exotic archs (s390, ppc, …) lack the "ALARM" flavour of the clocks. Thus, clock_gettime() will
@ -200,7 +198,7 @@ usec_t timespec_load(const struct timespec *ts) {
(usec_t) ts->tv_nsec / NSEC_PER_USEC;
}
static nsec_t timespec_load_nsec(const struct timespec *ts) {
nsec_t timespec_load_nsec(const struct timespec *ts) {
assert(ts);
if (ts->tv_sec == (time_t) -1 && ts->tv_nsec == (long) -1)

View file

@ -111,6 +111,7 @@ static inline bool triple_timestamp_is_set(triple_timestamp *ts) {
usec_t triple_timestamp_by_clock(triple_timestamp *ts, clockid_t clock);
usec_t timespec_load(const struct timespec *ts) _pure_;
nsec_t timespec_load_nsec(const struct timespec *ts) _pure_;
struct timespec *timespec_store(struct timespec *ts, usec_t u);
usec_t timeval_load(const struct timeval *tv) _pure_;

View file

@ -133,6 +133,10 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) {
if (r == 0 && *n)
return -EINVAL;
/* More than one trailing dot? */
if (*n == '.')
return -EINVAL;
if (sz >= 1 && d)
*d = 0;