aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-01-08 13:45:54 +0100
committerHarald Welte <laforge@gnumonks.org>2017-01-08 16:04:01 +0100
commitb8a70980b691e19661840529b2c6b2c28db0aa1f (patch)
tree8628edde91f67223b312680b04b94b808e2c9300
parent5fa552cbd386b7e32f219648ae7a4e46bededa43 (diff)
patch %s out of format strings received from phone
%s can obviously not work, as we have no access to the targets memory space on the host PC. I guess the programmers adding those log lines have done so in error. Let's replace %s with %p in the format string.
-rw-r--r--src/diag_msg.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/diag_msg.c b/src/diag_msg.c
index 0a96ce6..82c80bf 100644
--- a/src/diag_msg.c
+++ b/src/diag_msg.c
@@ -100,6 +100,12 @@ static void diag_rx_ext_msg_f(struct diag_instance *di, struct msgb *msgb)
printf("MSG(%u|%u|%s:%u): ", osmo_load16le(&msg->subsys_id),
diag_ts_to_epoch(osmo_load64le(&msg->hdr.timestamp)),
file, osmo_load16le(&msg->line_nr));
+
+ /* replace all '%s' with '%p', as %s obviously doesn't work */
+ for (char *cur = fmt; cur && (cur < fmt + strlen(fmt)); cur = strstr(fmt, "%s")) {
+ cur[1] = 'p';
+ }
+
switch (num_args) {
case 0:
fputs(fmt, stdout);