Commit Graph

14 Commits

Author SHA1 Message Date
Martin Storsjö
f2bd22acd5 Use char instead of str_t 2014-02-10 08:06:37 +02:00
Martin Storsjö
7b96c6756e Use void instead of void_t
There's really no reason for adding a typedef for void.
2014-02-10 08:06:33 +02:00
Martin Storsjö
fa93c88fa2 Implement WelsStrcat based on WelsStrncpy
This is a more convenient behaviour (truncating on overflow and
always null terminating the buffer) compared to the MSVC
safe strcat_s which aborts the process if the string doesn't fit
into the target buffer.

Also mark the source buffer as const in the function prototype.
2014-01-28 12:27:22 +02:00
Martin Storsjö
9840f11784 Remove the now unused count parameter to WelsStrncpy
Also remove manual null termination as WelsStrncpy now always
takes care of it.
2014-01-28 12:13:11 +02:00
Martin Storsjö
a16ccc0b4d Fix the implementations of WelsStrncpy
Make the MSVC "safe" version truncate instead of aborting the
process if the buffer is too small.

Update all the other functions to use the right parameter
(iSizeInBytes, not iCount) as 'n' parameter to strncpy.
(By passing iCount as parameter to the normal strncpy functions,
it meant that the resulting buffer actually never was null
terminated.)

Additionally make sure that the other implementations of WelsStrncpy
always null terminate the resulting buffer, just as the MSVC safe
version does when passed the _TRUNCATE parameter.
2014-01-28 12:08:35 +02:00
Martin Storsjö
9b59153263 Remove the STRNLEN/WelsStrnlen compatibility functions
These were essentially useless - if strlen() ever was used as
fallback, it either indicated that those ports of the library
were insecure, or that strnlen never was required at all.
In this case it turned out to be the latter (at least after
the preceding cleanups) - all uses of it were with known null
terminated strings.
2014-01-28 12:00:04 +02:00
Martin Storsjö
3559f425b4 Consistently use the compat wrappers for file IO
As long as WelsFileHandle* is equal to FILE* this doesn't matter,
but for consistency use the WelsF* functions for all handles
opened by WelsFopen, and use WelsFileHandle* as type for it
instead of FILE*.
2014-01-27 22:49:41 +02:00
Martin Storsjö
0439392a79 Fix a typo Millsecond -> Millisecond 2014-01-27 19:20:27 +02:00
Martin Storsjö
c7b74b2b12 Make sure the buffer is null terminated after strftime
If the buffer is too small, there's no guarantee that it is
null terminated. The docs (on both unix and MSVC) say explicitly
that the function returns 0 and the buffer contents are
indeterminate in this case.
2014-01-27 12:07:00 +02:00
Martin Storsjö
7884e77b2d Make sure the buffer always is null terminated in the *snprintf calls for old MSVC
These functions leave the buffer unterminated in case it was too
small.
2014-01-27 12:06:24 +02:00
Martin Storsjö
4a8f54d767 Use vsnprintf in the old MSVC version of WelsSnprintf as well 2014-01-27 12:06:08 +02:00
Martin Storsjö
0ce42ffb89 Rename WelsVsprintf to WelsVsnprintf, to indicate that it actually checks the length 2014-01-27 12:05:53 +02:00
Martin Storsjö
e42e82aa1f Make WelsVsprintf use vsnprintf, to check the buffer size
Otherwise builds on platforms other than MSVC might be
insecure.

Use vsnprintf_s with the _TRUNCATE flag instead of vsprintf_s
when using MSVC - this truncates the buffer instead of aborting
the whole process in case it's too small.
2014-01-27 12:05:39 +02:00
Martin Storsjö
2f5f25b7e3 Merge the encoder/decoder crt_util_safe_x.h into the common lib 2014-01-27 08:03:03 +02:00