Questions tagged [tr24731]

TR 24731 is a technical report prepared by the ISO C standardization committee, now partially incorporated as optional Annex K in the ISO/IEC 9899:2011 C Standard. Part 1 standardizes some safer bounds-checking functions for use in C and Part 2 relates to functions that do dynamic memory allocation.

The ISO C standardization committee (ISO/IEC JTC1/SC22/WG14) defined two technical reports:

  • TR 24731-1: Extensions to the C Library Part I: Bounds-checking interfaces

    This includes functions such as fopen_s() and strcpy_s() and sprintf_s(), which should be in some sense more secure than earlier analogs in the standard C library, checking for null pointers and buffer overflows. They are based on, but not identical with, functions with the same names in the Microsoft C library.

    It is included as the optional, but normative, Annex K in the current standard, ISO/IEC 9899:2011 'Programming Languages — C'.

    An evaluation from 2015 came to quite unflattering conclusions, basically wanting to recall it completely. n1967 Field Experience with Annex K - Bounds Checking Interfaces

  • TR 24731-2: Extensions to the C Library Part II: Dynamic allocation functions

    This includes functions such as asprintf() and vasprintf() which dynamically allocate enough space for the formatted output, and the getline() and getdelim() functions which are also defined in POSIX 2008, and strdup(). These were not standardized in C 2011.

65 questions
2
votes
2 answers

How to install C11 compiler on Mac OS with optional string functions included?

I'm trying the below code to see if the optional string functions in C are supported (I've got Mac OS X El Capitan and XCode installed)... #include int main(void) { #if defined __STDC_LIB_EXT1__ printf("Optional functions are…
Integralist
  • 5,899
  • 5
  • 25
  • 42
2
votes
1 answer

Visual Studio error in C, unhandled exception at 0xfefefefe

I am learning how to write C in Visual Studio, and here is my code, #include int main() { char me[20]; printf("What is your name?"); scanf_s("%s", me); printf("darn glad to meet you, %s!\n", me); return(0); } Now,…
user147271
  • 145
  • 2
  • 6
2
votes
3 answers

Using non-standard functions in Code::Blocks

I got this book "Beginning C" by Ivor Horton and I'm half way through it and I like it; so far so good. I use Code::Blocks on Windows as my IDE, and now I've run into the problem I cannot solve for about 3 days now. The author mentions some…
slamdunker
  • 67
  • 6
2
votes
1 answer

Can't get scanf_s or switch working

I'm having some problems with the scanf_s(); function or the switch function, the first time I run my code it doesn't recognize the correct char and loops back to the beginning, but after that it works just fine. It is a simple calculator. There…
2
votes
1 answer

undefined reference to `strcpy_s' can't compile

i follow the book and can't compile this example. Any suggestions? 1 #define __STDC_WANT_LIB_EXT1__ 1 2 #include 3 #include 4 5 6 int main(void) 7 { 8 char source[] = "Here we go..."; 9 char…
medis
  • 31
  • 1
  • 2
2
votes
2 answers

Undefined reference to gets_s?

I'm using gcc on Ubuntu 4.6.1 and SUSE 4.6.2 with the following command gcc gets_s.c My source code is // Read and Display Lines // gets_s.c #include int main(void) { char first_name[11]; char last_name[11]; …
1
vote
0 answers

Why is scanf() considered unsafe in Visual Studio?

Why is scanf() considered unsafe in Visual Studio? When in Visual Studio,I must use scanf_s instead of scanf.
Volta-Hsu
  • 19
  • 3
1
vote
1 answer

Where is the scanf_s() buffer defined?

If I didn't have access to the internet, but knew that I wanted to use the scanf_s() function to take input from the keyboard (stdin), how would I know where to declare the buffer? At the moment, when I step into the scanf_s() function in Visual…
sharkbites
  • 101
  • 1
  • 8
1
vote
1 answer

A Beginner's scanf_s() Disability

int main(void) { char tmp, arr[100]; int i, k; printf("Enter a string: "); scanf_s("%s", arr); for ( k = 0, i = (strlen(arr) - 1); k < (int) (strlen(arr) / 2); --i, ++k) { tmp = arr[k]; arr[k] = arr[i]; …
Davos Crisis
1
vote
2 answers

"string safe functions" and gcc

I'm using CodeBlocks and GCC compiler. I'd like to use "string safe functions" e.g strlen_s, strcpy_s, but compiler shows an error: Undefined reference to strlen_s. I then add a line to the code: #define __STDC_WANT_LIB_EXT1__ 1 As well as…
quark
  • 70
  • 9
1
vote
1 answer

Undefined symbols for architecture x86_64: "_gets_s"

I am attempting to compile an example program from an the book Beginning C 5th Ed. by Ivor Horton. Attempting to compile it on OSX and I am getting the following output from gcc: $ gcc program6_07.c program6_07.c:18:59: warning: format specifies…
cblanto7
  • 168
  • 1
  • 3
  • 12
1
vote
3 answers

Reading a character with scanf_s

I was just messing around with C and ran into this small problem. As you can see from my output I getting '╠' this character. #include int main(void) { char c; printf("Do you want to be X's or O's?\n"); scanf_s("%c", &c); …
1
vote
1 answer

Difference between scanf's width specification and scanf_s

scanf_s("%s", a, 10); This code will protect our program from buffer overflow exploit. But without scanf_s, we can write: scanf("%9s", a); I think this code will also block buffer overflow. Is this true? So what is basically different between two…
suhdonghwi
  • 955
  • 1
  • 7
  • 20
1
vote
1 answer

Implicit declaration of function 'scan_s' [-Wimplicit-function-declaration]

I've been looking at other questions and none of the solutions have worked so I'll ask my own question. I'm working on a linux VM and having trouble compiling my code, here are my includes, the error received by the compiler and the code its…
Sinn0n
  • 61
  • 2
1
vote
3 answers

Why is the scanf_s function not taking input correctly?

When I input a, the output is not a. Condition is true so why is the output not a?. When I use getchar instead of scanf_s, it works fine. What's the issue? char op; scanf_s("%c", &op); if ( op == 'a' ) printf("the character is a"); else …
Fahad Saleem
  • 413
  • 2
  • 13