Format specifier issue when building kernel

William Roberts bill.c.roberts at gmail.com
Tue Oct 29 03:55:08 UTC 2013


On Mon, Oct 28, 2013 at 6:43 PM, William Roberts
<bill.c.roberts at gmail.com>wrote:

>
>
>
> On Mon, Oct 28, 2013 at 6:35 PM, Richard Guy Briggs <rgb at redhat.com>wrote:
>
>> On Mon, Oct 28, 2013 at 04:31:30PM -0700, William Roberts wrote:
>> > On Mon, Oct 28, 2013 at 4:30 PM, William Roberts
>> > <bill.c.roberts at gmail.com>wrote:
>> >
>> > > I've been working off of Richard Guy Brigs git repo on branch
>> > > audit-for-next prepping my patch and I noticed a build warning:
>> > >
>> > > kernel/audit.c:832:8: warning: format ‘%A’ expects argument of type
>> > > ‘double’, but argument 3 has type ‘char *’ [-Wformat]
>> > >
>> > > Looking at the code, it looks wrong:
>> > >
>> > >                                 audit_log_format(ab,
>> >                                                  "
>> > msg='%.AUDIT_MESSAGE_TEXT_MAXs'",
>> >                                                  (char *)data);
>> >
>> > The issue appears on the % specifier in there, it picks it up as %.A,
>> which
>> > is of type double. Is this what was intended?
>>
>> Hmmm, that should have picked up a macro from 06051fbe in
>> audit-for-next.  It should be pre-processed to "%.8560s".
>>
>> > William C Roberts
>>
>>
>> - RGB
>>
>>
> The qoutes are wrong for that.
>

Ok I see the value is not a string, but a numeric constant. Dont you need
to do something like this:
diff --git a/kernel/audit.c b/kernel/audit.c
index bf4b1af..81dde3d 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -825,10 +825,12 @@ static int audit_receive_msg(struct sk_buff *skb,
struct nlmsghdr *nlh)
                                if (err)
                                        break;
                        }
+#define STR_HELPER(x) #x
+#define STR(x) STR_HELPER(x)
                        audit_log_common_recv_msg(&ab, msg_type);
                        if (msg_type != AUDIT_USER_TTY)
                                audit_log_format(ab,
-                                                "
msg='%.AUDIT_MESSAGE_TEXT_MAXs'",
+                                                "
msg='%."STR(AUDIT_MESSAGE_TEXT_MAX)"s'",
                                                 (char *)data);
                        else {
                                int size;


Unless their is some gnu-magic I don't know about.



> <snip>
>
>
>

-- 
Respectfully,

William C Roberts
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/linux-audit/attachments/20131028/e3a8fe61/attachment.htm>


More information about the Linux-audit mailing list