static int process_dunder(JournalImporter *imp, char *line, size_t n) {
const char *timestamp;
+ char buf[CELLESCAPE_DEFAULT_LENGTH];
int r;
assert(line);
timestamp = startswith(line, "__REALTIME_TIMESTAMP=");
if (timestamp) {
uint64_t x;
+
line[n-1] = '\0';
r = safe_atou64(timestamp, &x);
if (r < 0)
- return log_warning_errno(r, "Failed to parse __REALTIME_TIMESTAMP '%s': %m", timestamp);
+ return log_warning_errno(r, "Failed to parse __REALTIME_TIMESTAMP '%s': %m",
+ cellescape(buf, sizeof buf, timestamp));
else if (!VALID_REALTIME(x)) {
log_warning("__REALTIME_TIMESTAMP out of range, ignoring: %"PRIu64, x);
return -ERANGE;
timestamp = startswith(line, "__MONOTONIC_TIMESTAMP=");
if (timestamp) {
uint64_t x;
+
line[n-1] = '\0';
r = safe_atou64(timestamp, &x);
if (r < 0)
- return log_warning_errno(r, "Failed to parse __MONOTONIC_TIMESTAMP '%s': %m", timestamp);
+ return log_warning_errno(r, "Failed to parse __MONOTONIC_TIMESTAMP '%s': %m",
+ cellescape(buf, sizeof buf, timestamp));
else if (!VALID_MONOTONIC(x)) {
log_warning("__MONOTONIC_TIMESTAMP out of range, ignoring: %"PRIu64, x);
return -ERANGE;
timestamp = startswith(line, "__");
if (timestamp) {
- log_notice("Unknown dunder line %s, ignoring.", line);
+ log_notice("Unknown dunder line __%s, ignoring.", cellescape(buf, sizeof buf, timestamp));
return 1;
}
char *ellipsize(const char *s, size_t length, unsigned percent);
char *cellescape(char *buf, size_t len, const char *s);
+/* This limit is arbitrary, enough to give some idea what the string contains */
+#define CELLESCAPE_DEFAULT_LENGTH 64
+
bool nulstr_contains(const char *nulstr, const char *needle);
char* strshorten(char *s, size_t l);