<commit_before>/*
 *  (C) Copyright 2001-2006 <NAME> <<EMAIL>>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License Version
 *  2.1 as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
 *  USA.
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include "libgadu.h"
#include "internal.h"
#include "fileio.h"

static inline int
gg_mkstemp(char *path)
{
	mode_t old_umask;
	int ret;

	old_umask = umask(S_IRWXO | S_IRWXG);
#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500)
	ret = mkstemp(path);
#else
	/* coverity[secure_temp : FALSE]
	 *
	 * mktemp may be unsafe, because it creates files with predictable
	 * names, but it's not a real problem for automatic tests.
	 */
	if (strcmp(mktemp(path), "") == 0)
		ret = -1;
	else /* XXX: O_CREAT shouldn't be necessary */
		ret = open(path, O_EXCL | O_RDWR | O_CREAT);
#endif
	umask(old_umask);

	return ret;
}

static char *sha1_to_string(uint8_t *sha1)
{
	static char str[41];
	size_t i;

	for (i = 0; i < 20; i++)<commit_msg>Use _mktemp_s on win32, which is more secure than mktemp<commit_after>/*
 *  (C) Copyright 2001-2006 <NAME> <<EMAIL>>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License Version
 *  2.1 as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
 *  USA.
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include "libgadu.h"
#include "internal.h"
#include "fileio.h"

static inline int
gg_mkstemp(char *path)
{
	mode_t old_umask;
	int ret;

	old_umask = umask(S_IRWXO | S_IRWXG);
#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500)
	ret = mkstemp(path);
#else
#ifdef _WIN32
	if (_mktemp_s(path, strlen(path)) != 0)
#else
	/* coverity[secure_temp : FALSE]
	 *
	 * mktemp may be unsafe, because it creates files with predictable
	 * names, but it's not a real problem for automatic tests.
	 */
	if (strcmp(mktemp(path), "") == 0)
#endif
		ret = -1;
	else /* XXX: O_CREAT shouldn't be necessary */
		ret = open(path, O_EXCL | O_RDWR | O_CREAT);
#endif
	umask(old_umask);

	return ret;
}

static char *sha1_to_string(uint8_t *sha1)
{
	static char str[41];
	size_t i;

	for (i = 0; i < 20; i++)
{'fraction_non_alphanumeric': 0.10865010475905418, 'fraction_numerical': 0.0236456150853038, 'mean_word_length': 3.9437869822485205, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3475997', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1132, 'n_words': 422}