chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
shared: call va_end in all cases
[elogind.git]
/
src
/
shared
/
util.c
diff --git
a/src/shared/util.c
b/src/shared/util.c
index 69c9437db83a826826435bcddbb04603cab02100..97f766c33c5b043559472d3b6817d442626c4bc1 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-1184,8
+1184,11
@@
char *strnappend(const char *s, const char *suffix, size_t b) {
assert(suffix);
a = strlen(s);
assert(suffix);
a = strlen(s);
+ if (b > ((size_t) -1) - a)
+ return NULL;
- if (!(r = new(char, a+b+1)))
+ r = new(char, a+b+1);
+ if (!r)
return NULL;
memcpy(r, s, a);
return NULL;
memcpy(r, s, a);
@@
-2956,9
+2959,10
@@
int dir_is_empty(const char *path) {
return -errno;
for (;;) {
return -errno;
for (;;) {
- struct dirent buf, *de;
+ struct dirent *de;
+ union dirent_storage buf;
- r = readdir_r(d, &buf, &de);
+ r = readdir_r(d, &buf
.de
, &de);
if (r > 0)
return -r;
if (r > 0)
return -r;
@@
-3260,12
+3264,13
@@
int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct
}
for (;;) {
}
for (;;) {
- struct dirent buf, *de;
+ struct dirent *de;
+ union dirent_storage buf;
bool is_dir, keep_around;
struct stat st;
int r;
bool is_dir, keep_around;
struct stat st;
int r;
- r = readdir_r(d, &buf, &de);
+ r = readdir_r(d, &buf
.de
, &de);
if (r != 0 && ret == 0) {
ret = -r;
break;
if (r != 0 && ret == 0) {
ret = -r;
break;
@@
-4942,10
+4947,11
@@
int get_files_in_directory(const char *path, char ***list) {
return -errno;
for (;;) {
return -errno;
for (;;) {
- struct dirent buffer, *de;
+ struct dirent *de;
+ union dirent_storage buf;
int k;
int k;
- k = readdir_r(d, &buf
fer
, &de);
+ k = readdir_r(d, &buf
.de
, &de);
if (k != 0) {
r = -k;
goto finish;
if (k != 0) {
r = -k;
goto finish;
@@
-5011,12
+5017,19
@@
char *strjoin(const char *x, ...) {
for (;;) {
const char *t;
for (;;) {
const char *t;
+ size_t n;
t = va_arg(ap, const char *);
if (!t)
break;
t = va_arg(ap, const char *);
if (!t)
break;
- l += strlen(t);
+ n = strlen(t);
+ if (n > ((size_t) -1) - l) {
+ va_end(ap);
+ return NULL;
+ }
+
+ l += n;
}
} else
l = 0;
}
} else
l = 0;
@@
-5288,7
+5301,7
@@
int signal_from_string(const char *s) {
int offset = 0;
unsigned u;
int offset = 0;
unsigned u;
- signo =__signal_from_string(s);
+ signo =
__signal_from_string(s);
if (signo > 0)
return signo;
if (signo > 0)
return signo;
@@
-5680,7
+5693,7
@@
void warn_melody(void) {
if (fd < 0)
return;
if (fd < 0)
return;
- /* Yeah, this is synchronous. Kinda sucks. But
e
well... */
+ /* Yeah, this is synchronous. Kinda sucks. But well... */
ioctl(fd, KIOCSOUND, (int)(1193180/440));
usleep(125*USEC_PER_MSEC);
ioctl(fd, KIOCSOUND, (int)(1193180/440));
usleep(125*USEC_PER_MSEC);