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
1
vote
2 answers

I am having trouble with multiple chars and scanf_s()

I'm trying to use scanf_s() to read in multiple values but every time I run the program, I get Unhandled exception at 0x592AD6AC (msvcr120d.dll) in lab 2.exe: 0xC0000005: Access violation writing location 0x00000000. in a popup window. How do I…
1
vote
1 answer

Why fopen_s returns EEXIST (errno 17) when opening file for reading

When I execute fopen_s(&fid, FILE_NAME, "r"), fid is null and errno is 17. How is this even possible that when I try to open a file for reading I get EEXIST error?
fudge
  • 276
  • 5
  • 14
1
vote
2 answers

What is the oldest version of gcc/glibc that supports the strerrorlen_s and strerror_s functions?

I'm having trouble using strerrorlen_s in gcc 4.7.2 even though I defined __STDC_WANT_LIB_EXT1__ 1.
clockley1
  • 464
  • 5
  • 16
0
votes
0 answers

Use memcpy_s in c++

I am using c++. I want to build code which contains memcpy_s on linux. I am using gcc 9.3. I made some modifications. #ifdef __cplusplus extern "C" { #define _STDC_WANT_LIB_EXT1_ 1 #include } #endif void doMemCopy(char* buf, size_t…
Vladimir Yanakiev
  • 1,240
  • 1
  • 16
  • 25
0
votes
2 answers

I'm using Linux, compiling with gcc, getting error: warning: implicit declaration of function ‘fopen_s’, can someone help me fix this?

I'm trying to write a simple edge detection program in c. I'm using Red Hat Enterprise Linux Server 7.7 (Maipo), and gcc version 4.8.5. This is the start of the code: #include #define size 200 int _tmain(int argc, _TCHAR* argv[]) { …
Rice Man
  • 415
  • 1
  • 5
  • 16
0
votes
0 answers

second scanf_s would skip if the first scanf_s contains more than one words

void main() { char name[64], identity[64]; printf("Welcome to ABC Computer Store!\n"); printf("Please enter your name: "); scanf_s("%s", &name, 63); printf("Please enter your IC/Passport: "); scanf_s("%s", &identity,…
Lucas Chan
  • 87
  • 6
0
votes
1 answer

scanf_s returning Null every time

I am using scanf_s to two different inputs and place them into char arrays. I have attached the code and the output it gives char firstName[30]; char lastName[30]; int main() { // Input Name printf("Please input your name: "); scanf_s("%s %s",…
0
votes
0 answers

How to use strncpy_s in gcc?

i am trying t use strncpy_s functionality in my C++ program , but my code is unable to reach strncpy_s , due to macro defined , please let me know how to use strncpy_s in gcc , thanks in advance, my code is as below #define…
0
votes
2 answers

Get_s function not working

My book says the get_s() function is a better alternative to the gets() function, which is deprecated and should not be used. But, when I try to use the get_s() function it always gives me an error: undefined reference to gets_s This page says…
BumbleBee
  • 87
  • 2
  • 16
0
votes
3 answers

Getting an "implicit declaration of function" error in Code Blocks

I am still quite new to C, and I keep getting an error in Code Blocks which stops me from running my programs. I get the error "implicit declaration of functions printf_s() and scanf_s(). Here is my code: #define __STDC_WANT_LIB_EXT1__ 1 #include…
ThE411
  • 33
  • 8
0
votes
1 answer

scanf_s not enough arguments passed for format string(Visual Studio)

The program showing error as title. What's wrong on scanf_s function? Any idea? Thanks in advance. int main() { struct Students { char name[10]; int snum; float point; }st[5]; int…
Nicat Muzaffarli
  • 105
  • 4
  • 10
0
votes
1 answer

Is strcpy_s part of the C++ Standard? Or only part of MS Visual C++

Using the function strcpy in MS Visual Studio gives me an error saying I should use strcpy_s which is safer to use. Is strcpy_s part of the C++ standard? Or is it only part of Microsoft Visual C++? Will code containing strcpy_s only compile in…
Jorge Luque
  • 435
  • 1
  • 4
  • 17
0
votes
2 answers

"wcs" and "_w" and "_mbs" prefix in Visual Studio

I am a little confused with respect to the difference in the functions which are defined with/without the wcs/_w/_mbs prefix. For Example: fopen(),_wfopen() On msdn it is given that: The fopen function opens the file that is specified by…
rnjai
  • 1,065
  • 2
  • 17
  • 32
0
votes
2 answers

Simple program using strings

I don't know what is wrong with the following code. Maybe scanf_s won't scan the string name. int main(void) { char *name[20]; printf("What is your name>"); scanf_s("%s", name); printf("Your name is %s\n", name); return 0; } I…
-1
votes
1 answer

Why does this sprintf_s throw an exception?

char filePrefix[] = "test"; char fileName[100]; fileName[0] = 0; sprintf_s(fileName, "%s", filePrefix); I can't figure out why there's an exception writing into fileName in the sprintf_s Exception thrown at 0x00007FF885E3F3A9 (ucrtbased.dll) in…
nicomp
  • 4,344
  • 4
  • 27
  • 60