• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: unsafe printing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unsafe printing


  • Subject: Re: unsafe printing
  • From: Steve Mills <email@hidden>
  • Date: Fri, 10 Jul 2015 20:07:41 +0000 (GMT)

On Jul 10, 2015, at 02:57 PM, "Jan E. Schotsman" <email@hidden> wrote:

How can I get rid of warnings about unsafe use of printf?

char myString[256];

// set myString in some untransparent way

printf( myString ); // warning: format string is not a literal 

Temporarily turn off the warning:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
printf(myString);
#pragma GCC diagnostic pop

Better yet, don't do that, *because it's potentially insecure*. Just do this instead:

printf("%s", myString);

Sent from iCloud (got I hate this editor)

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: unsafe printing
      • From: "Jan E. Schotsman" <email@hidden>
    • Re: unsafe printing
      • From: Jens Alfke <email@hidden>
  • Prev by Date: unsafe printing
  • Next by Date: Re: unsafe printing
  • Previous by thread: Re: unsafe printing
  • Next by thread: Re: unsafe printing
  • Index(es):
    • Date
    • Thread