• 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
_FORTIFY_SOURCE and strncat(), buggy?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

_FORTIFY_SOURCE and strncat(), buggy?


  • Subject: _FORTIFY_SOURCE and strncat(), buggy?
  • From: "Sean McBride" <email@hidden>
  • Date: Thu, 24 Jul 2008 14:19:58 -0400
  • Organization: Rogue Research

Hi all,

Anyone else out there using _FORTIFY_SOURCE?  Do you find it reliable?

The following code seems correct to me, but dies with _FORTIFY_SOURCE enabled.

--------------
#include <stdlib.h>
#include <string.h>

int main (int argc, const char * argv[])
{
	(void)argc; (void)argv;

	size_t size = 50;
	char* buffer = (char*)calloc(size, 1);
//	buffer[0] = 'q';	// uncomment this to 'fix'.

	strncat(buffer, "test", (size-1));

	return 0;
}
--------------

$ gcc-4.2 -Wall -D_FORTIFY_SOURCE=2 ~/Desktop/strncat_test.c
$ ./a.out
Abort trap

(PS: yes, I know C strings suck; yes, I know about strlcat).

Cheers,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


 _______________________________________________
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: _FORTIFY_SOURCE and strncat(), buggy?
      • From: Eric Slosser <email@hidden>
  • Prev by Date: Re: 3.1 errors building against 10.5 sdk
  • Next by Date: Re: Scroll area jumps when typing a single or double-quote
  • Previous by thread: Re: Scroll area jumps when typing a single or double-quote
  • Next by thread: Re: _FORTIFY_SOURCE and strncat(), buggy?
  • Index(es):
    • Date
    • Thread