summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2011-05-03 22:32:48 +0200
committerHarald Welte <laforge@gnumonks.org>2011-05-04 11:07:13 +0200
commit534ba8132818524bdf52d5dcf249dda51f766efb (patch)
tree93620569e4e3ba32fa8a5f7cdbb480577ba17854
parent81e9636454294ae10ef9bc8bf149dd0248afce76 (diff)
logging: make sure the output is null-terminated
If we reach the buffer size or snprintf fails, we want to make sure that the output is null-terminated.
-rw-r--r--src/logging.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/logging.c b/src/logging.c
index 6797afcd..0911010a 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -493,6 +493,7 @@ const char *log_vty_command_string(const struct log_info *info)
goto err;
OSMO_SNPRINTF_RET(ret, rem, offset, len);
err:
+ str[size-1] = '\0';
return str;
}
@@ -544,6 +545,7 @@ const char *log_vty_command_description(const struct log_info *info)
OSMO_SNPRINTF_RET(ret, rem, offset, len);
}
err:
+ str[size-1] = '\0';
return str;
}