-
Notifications
You must be signed in to change notification settings - Fork 0
liulk/strxcpy
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
strxcpy---More Consistent, Safer String Copying and Concatenation Copyright (c) 2009, 2010 Likai Liu <liulk@cs.bu.edu> https://code.google.com/p/strxcpy/ The C language makes it easy to write programs with buffer overflow problems, but there is still something the library can do to help the programmer make fewer mistakes. For this reason, we propose strxcpy(), a variant of strcpy() and strcat(), which combines both string copying and concatenation. char *strxcpy(char *dest, const char *dest_end, const char *src, size_t n); The function takes two parameters to define the buffer, dest and dest_end. It guarantees that it will not overwrite the memory location past dest_end, and the string at dest is always NUL terminated. Furthermore, it does not require dest to be a NUL terminated string. The return value is a character pointer to the NUL terminator of the dest string, so that we can easily append another string to it by calling strxcpy() again. We also propose the sprintf() variants using the same idiom. char *vsxprintf(char *dest, const char *dest_end, const char *fmt, va_list ap); char *sxprintf(char *dest, const char *dest_end, const char *fmt, ...); See this blog post [1] for the motivation of buffer overflow problems. [1] http://lifecs.likai.org/2010/06/strxcpymore-consistent-safer-string.html Additional documentation can be found inside the header file stringx.h.
About
Automatically exported from code.google.com/p/strxcpy
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published