Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 831 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Add safety string functions ("strcpy_s", etc.) #478933
01/21/20 11:56
01/21/20 11:56
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
jcl,

Can the following string/memory functions be added to Zorro's Lite-C library?
Code
errno_t strcpy_s( char *dest, rsize_t dest_size, const char *src);
int sprintf_s(char *buffer,  size_t sizeOfBuffer,  const char *format,  ...);
errno_t strcat_s(char *strDestination, size_t numberOfElements, const char *strSource);
errno_t memcpy_s(void *dest,   size_t destSize,   const void *src,   size_t count);
Thanks,
Andrew

Re: Add safety string functions ("strcpy_s", etc.) [Re: AndrewAMD] #478944
01/22/20 13:36
01/22/20 13:36
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Yes, we can add them to stdio.h.

Re: Add safety string functions ("strcpy_s", etc.) [Re: AndrewAMD] #478946
01/22/20 15:25
01/22/20 15:25
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Thank you!

Re: Add safety string functions ("strcpy_s", etc.) [Re: AndrewAMD] #478955
01/25/20 16:32
01/25/20 16:32
Joined: Oct 2017
Posts: 56
Munich
K
kalmar Offline
Junior Member
kalmar  Offline
Junior Member
K

Joined: Oct 2017
Posts: 56
Munich
Hi, Andrew,

Could you please explain a bit the idea behind?

Thank you!

Re: Add safety string functions ("strcpy_s", etc.) [Re: AndrewAMD] #478956
01/25/20 16:43
01/25/20 16:43
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
These functions require the programmer to define the sizes of the buffer being written to.

If the function detects that the output buffer is too small, then it will, depending on the settings/implementation:
* Halt the program and clearly explain what the problem is.
* Throw an exception (not supported in Lite-C).
* Or simply return an error, and then the programmer can handle it manually without aborting the program.
* A callback function can be used in the event of any of the above.

In all cases, the bad buffer write does not occur.

Interestingly, the git project has banned all uses of strcpy(), strcat(), and sprintf() using a header:
https://github.com/git/git/blob/master/banned.h

Background: I just had to scrub one of my trading systems clean because it was crashing under mysterious circumstances. After much work, the bug disappeared for reasons unknown.

Murphy's Law: Things that can go wrong will go wrong. It's better to try to get things right the first time around.

[Linked Image]

Attached Files developers_projects.jpg

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1