chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Properly check for overflow in offsets
[elogind.git]
/
src
/
shared
/
logs-show.c
diff --git
a/src/shared/logs-show.c
b/src/shared/logs-show.c
index b88547eb83a47c6968cd92efd9e8204042242fc4..013a281eacdf8627cd5c2cee45ea95c96d294a0e 100644
(file)
--- a/
src/shared/logs-show.c
+++ b/
src/shared/logs-show.c
@@
-163,7
+163,7
@@
static int output_short(
sd_journal_set_data_threshold(j, flags & OUTPUT_SHOW_ALL ? 0 : PRINT_THRESHOLD);
sd_journal_set_data_threshold(j, flags & OUTPUT_SHOW_ALL ? 0 : PRINT_THRESHOLD);
-
SD_JOURNAL_FOREACH_DATA(j, data, length
) {
+
JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r
) {
r = parse_field(data, length, "PRIORITY=", &priority, &priority_len);
if (r < 0)
r = parse_field(data, length, "PRIORITY=", &priority, &priority_len);
if (r < 0)
@@
-218,6
+218,9
@@
static int output_short(
return r;
}
return r;
}
+ if (r < 0)
+ return r;
+
if (!message)
return 0;
if (!message)
return 0;
@@
-240,7
+243,7
@@
static int output_short(
r = sd_journal_get_monotonic_usec(j, &t, &boot_id);
if (r < 0) {
r = sd_journal_get_monotonic_usec(j, &t, &boot_id);
if (r < 0) {
- log_error("Failed to get monotonic: %s", strerror(-r));
+ log_error("Failed to get monotonic
timestamp
: %s", strerror(-r));
return r;
}
return r;
}
@@
-265,7
+268,7
@@
static int output_short(
r = sd_journal_get_realtime_usec(j, &x);
if (r < 0) {
r = sd_journal_get_realtime_usec(j, &x);
if (r < 0) {
- log_error("Failed to get realtime: %s", strerror(-r));
+ log_error("Failed to get realtime
timestamp
: %s", strerror(-r));
return r;
}
return r;
}
@@
-336,7
+339,8
@@
static int output_verbose(
r = sd_journal_get_realtime_usec(j, &realtime);
if (r < 0) {
r = sd_journal_get_realtime_usec(j, &realtime);
if (r < 0) {
- log_error("Failed to get realtime timestamp: %s", strerror(-r));
+ log_full(r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_ERR,
+ "Failed to get realtime timestamp: %s", strerror(-r));
return r;
}
return r;
}
@@
-350,7
+354,7
@@
static int output_verbose(
format_timestamp(ts, sizeof(ts), realtime),
cursor);
format_timestamp(ts, sizeof(ts), realtime),
cursor);
-
SD_JOURNAL_FOREACH_DATA(j, data, length
) {
+
JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r
) {
const char *c;
int fieldlen;
c = memchr(data, '=', length);
const char *c;
int fieldlen;
c = memchr(data, '=', length);
@@
-373,6
+377,9
@@
static int output_verbose(
}
}
}
}
+ if (r < 0)
+ return r;
+
if (flags & OUTPUT_CATALOG)
print_catalog(f, j);
if (flags & OUTPUT_CATALOG)
print_catalog(f, j);
@@
-426,7
+433,7
@@
static int output_export(
(unsigned long long) monotonic,
sd_id128_to_string(boot_id, sid));
(unsigned long long) monotonic,
sd_id128_to_string(boot_id, sid));
-
SD_JOURNAL_FOREACH_DATA(j, data, length
) {
+
JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r
) {
/* We already printed the boot id, from the data in
* the header, hence let's suppress it here */
/* We already printed the boot id, from the data in
* the header, hence let's suppress it here */
@@
-455,6
+462,9
@@
static int output_export(
fputc('\n', f);
}
fputc('\n', f);
}
+ if (r < 0)
+ return r;
+
fputc('\n', f);
return 0;
fputc('\n', f);
return 0;
@@
-583,7
+593,7
@@
static int output_json(
return -ENOMEM;
/* First round, iterate through the entry and count how often each field appears */
return -ENOMEM;
/* First round, iterate through the entry and count how often each field appears */
-
SD_JOURNAL_FOREACH_DATA(j, data, length
) {
+
JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r
) {
const char *eq;
char *n;
unsigned u;
const char *eq;
char *n;
unsigned u;
@@
-617,6
+627,9
@@
static int output_json(
}
}
}
}
+ if (r < 0)
+ return r;
+
separator = true;
do {
done = true;
separator = true;
do {
done = true;
@@
-997,7
+1010,7
@@
int show_journal_by_unit(
_cleanup_journal_close_ sd_journal*j = NULL;
int r;
_cleanup_journal_close_ sd_journal*j = NULL;
int r;
- int jflags = SD_JOURNAL_LOCAL_ONLY | system * SD_JOURNAL_SYSTEM
_ONLY
;
+ int jflags = SD_JOURNAL_LOCAL_ONLY | system * SD_JOURNAL_SYSTEM;
assert(mode >= 0);
assert(mode < _OUTPUT_MODE_MAX);
assert(mode >= 0);
assert(mode < _OUTPUT_MODE_MAX);