linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andriot <andriot@6wind.com>
To: Hendrik Visage <hvjunk@gmail.com>
Cc: Ankit Jain <ankitjain1580@yahoo.com>,
	linux prg <linux-c-programming@vger.kernel.org>,
	newbie <linux-newbie@vger.kernel.org>
Subject: Re: Printf and scanf
Date: Mon, 27 Jun 2005 20:11:03 +0200	[thread overview]
Message-ID: <20050627181103.ABFB324F@eagle.6wind.com> (raw)
In-Reply-To: <d93f04c70506241420114b28da@mail.gmail.com>

Hendrik Visage wrote:

>On 6/5/05, Ankit Jain <ankitjain1580@yahoo.com> wrote:
>
>  
>
>>i just want to know how scanf function can be used on
>>the place of printf and vice versa
>>    
>>
>
>In the Obfuscated C contest one of the first/early entries is one that
>states "Using read to write" (Or something to similar extend, or
>perhaps even using scanf to print). Reading that code is hackery, and
>from my first glance at the code, it was don't with quote and macro
>hackery.
>
>Thus you could #define scanf __prinf and #define printf __scanf... or
>something with similar confusing
>  
>

Of course, it is not possible to use directly printf like a scanf ;)
But you can use printf to write some values into arguments when you call 
the function. This uses special caracters you put in the format string. 
And this should prevent you to call printf with a string the user wrote, 
because this is a very big security hole.

JP



      reply	other threads:[~2005-06-27 18:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-05 12:21 Printf and scanf Ankit Jain
2005-06-05 13:54 ` Arturas Moskvinas
2005-06-05 14:03   ` Eric Bambach
2005-06-24 21:20 ` Hendrik Visage
2005-06-27 18:11   ` Andriot [this message]

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=20050627181103.ABFB324F@eagle.6wind.com \
    --to=andriot@6wind.com \
    --cc=ankitjain1580@yahoo.com \
    --cc=hvjunk@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=linux-newbie@vger.kernel.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).