This patch converts a stack allocated buffer into an std::ostringstream object. The stringstream interface for specifying the equivalent of a printf %02x conversion is a bit of an awkward construction, however.
Signed-off-by: Steve Beattie <st...@nxnw.org> --- parser/parser_regex.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) Index: b/parser/parser_regex.c =================================================================== --- a/parser/parser_regex.c +++ b/parser/parser_regex.c @@ -24,7 +24,10 @@ #include <sys/apparmor.h> #define _(s) gettext(s) +#include <iomanip> #include <string> +#include <sstream> + /* #define DEBUG */ @@ -1018,7 +1021,7 @@ static int process_dbus_entry(aare_rules std::string pathbuf; std::string ifacebuf; std::string memberbuf; - char buffer[128]; + std::ostringstream buffer; const char *vec[6]; pattern_t ptype; @@ -1027,8 +1030,8 @@ static int process_dbus_entry(aare_rules if (!entry) /* shouldn't happen */ return TRUE; - sprintf(buffer, "\\x%02x", AA_CLASS_DBUS); - busbuf.append(buffer); + buffer << "\\x" << std::setfill('0') << std::setw(2) << std::hex << AA_CLASS_DBUS; + busbuf.append(buffer.str()); if (entry->bus) { ptype = convert_aaregex_to_pcre(entry->bus, 0, busbuf, &pos); -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor