[PATCH] msvcrt: Add tmpnam_s() and _wtmpnam_s() with tests.
Piotr Caban
piotr.caban at gmail.com
Thu Dec 10 07:07:35 CST 2015
Hi,
it this patch fixing any application or is it only letting it execute a
little further?
It doesn't compile:
../../../wine_src/dlls/msvcr71/msvcr71.spec:667: function
'MSVCRT_wtmpnam' not defined
../../../wine_src/dlls/msvcr70/msvcr70.spec:671: function
'MSVCRT_wtmpnam' not defined
...
On 12/10/15 00:08, lejcik wrote:
> /*********************************************************************
> + * tmpnam_s (MSVCRT.@)
> + */
> +int CDECL MSVCRT_tmpnam_s(char *s, MSVCRT_size_t size)
> +{
> + char tmpstr[16];
> + char *p;
> + int count, tmpsize;
> +
> + if (!MSVCRT_CHECK_PMT(s != NULL))
> + return MSVCRT_EINVAL;
> +
> + msvcrt_int_to_base32(GetCurrentProcessId(), tmpstr);
> + tmpsize = MSVCRT__snprintf(s, size, "\\s%s.", tmpstr);
> + if (tmpsize == -1)
> + return MSVCRT_ERANGE;
> +
> + p = s + tmpsize;
You can reuse s variable here (s += tmpsize).
> + size -= tmpsize;
> + for (count = 0; count < MSVCRT_TMP_MAX; count++)
According to MSDN TMP_MAX_S should be used here. It's different then
TMP_MAX.
> + {
> + tmpsize = msvcrt_int_to_base32(tmpnam_unique++, tmpstr);
> + if ((MSVCRT_size_t) tmpsize > size)
> + return MSVCRT_ERANGE;
Is invalid parameter handler called in this case?
> char * CDECL MSVCRT_tmpnam(char *s)
> {
...
> + return MSVCRT_tmpnam_s(s, MAX_PATH) == 0 ? s : NULL;
You can't use tmpnam_s here because of TMP_MAX and TMP_MAX_S inequality
(unless MSDN is wrong here).
Thanks,
Piotr
More information about the wine-devel
mailing list