From: Damir Shayhutdinov <damir@altlinux.org>
To: ALT Linux Team development discussions <devel@lists.altlinux.org>
Subject: Re: [devel] Добавление -Werror=format-security
Date: Wed, 3 Jun 2009 15:59:10 +0400
Message-ID: <679044850906030459k539b55c0w737fbe9cd3b713e8@mail.gmail.com> (raw)
In-Reply-To: <679044850906030452k38ec3ec7g8b7faed19104fe34@mail.gmail.com>
>> А как правильно предлагается чинить подобное? Я чинил приведением типа и/или
>> заменой *printf на puts/fputs - так можно?
>
> puts/fputs или printf("%s", str); Лучше первое.
Причем обе конструкции компилируются в один и тот же код, при -O2.
Вот, сравните:
#include <stdio.h>
int main(void)
{
const char* p = "test!\n";
printf("%s", p);
puts(p);
return 0;
}
08048390 <main>:
8048390: 8d 4c 24 04 lea 0x4(%esp),%ecx
8048394: 83 e4 f0 and $0xfffffff0,%esp
8048397: ff 71 fc pushl 0xfffffffc(%ecx)
804839a: 55 push %ebp
804839b: 89 e5 mov %esp,%ebp
804839d: 51 push %ecx
804839e: 83 ec 10 sub $0x10,%esp
80483a1: 68 a0 84 04 08 push $0x80484a0
80483a6: e8 e9 fe ff ff call 8048294 <puts@plt>
80483ab: c7 04 24 a6 84 04 08 movl $0x80484a6,(%esp)
80483b2: e8 dd fe ff ff call 8048294 <puts@plt>
80483b7: 8b 4d fc mov 0xfffffffc(%ebp),%ecx
80483ba: 31 c0 xor %eax,%eax
80483bc: c9 leave
80483bd: 8d 61 fc lea 0xfffffffc(%ecx),%esp
80483c0: c3 ret
И там и там вызывается puts@plt.
next prev parent reply other threads:[~2009-06-03 11:59 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-03 1:21 Vitaly Lipatov
2009-06-03 4:15 ` Afanasov Dmitry
2009-06-03 5:41 ` Pavel Solntsev
2009-06-03 7:45 ` Led
2009-06-03 8:28 ` Pavel Solntsev
2009-06-03 10:23 ` Michael Shigorin
2009-06-03 10:32 ` Alexey Rusakov
2009-06-03 10:54 ` Dmitry V. Levin
2009-06-03 11:20 ` Dmitry V. Levin
2009-06-03 11:35 ` Ivan A. Melnikov
2009-06-03 11:49 ` Led
2009-06-03 11:52 ` Slava Semushin
2009-06-03 11:52 ` Damir Shayhutdinov
2009-06-03 11:59 ` Damir Shayhutdinov [this message]
2009-06-03 12:07 ` Led
2009-06-03 12:10 ` Damir Shayhutdinov
2009-06-03 12:04 ` Led
2009-06-03 11:54 ` Afanasov Dmitry
2009-06-03 12:05 ` Led
2009-06-03 12:11 ` Afanasov Dmitry
2009-06-03 12:19 ` Led
2009-06-03 13:12 ` Afanasov Dmitry
2009-06-03 21:23 ` Dmitry V. Levin
2009-06-03 21:14 ` Dmitry V. Levin
2009-06-03 21:30 ` Alexey Tourbin
2009-06-03 21:36 ` Dmitry V. Levin
2009-06-03 22:05 ` Led
2009-06-03 22:45 ` Dmitry V. Levin
2009-06-04 3:13 ` Alexey Tourbin
2009-06-04 20:14 ` Alexey Rusakov
2009-06-04 20:30 ` Led
2009-06-06 12:42 ` [devel] [JT] icc (was: Добавление -Werror=format-security) Michael Shigorin
2009-06-06 22:12 ` Konstantin Pavlov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=679044850906030459k539b55c0w737fbe9cd3b713e8@mail.gmail.com \
--to=damir@altlinux.org \
--cc=devel@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git