summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2020-05-30 11:06:57 +0200
committerDaiki Ueno <ueno@gnu.org>2020-05-30 11:10:12 +0200
commit14e2203ce5d7a6bbe050861a1206873a040674e3 (patch)
tree11e6dc0698f3d4840dc01c2c537064acf79ad685 /lib
parent1976600876a3f0724b52c61d96998560dc4c0acb (diff)
downloadgnutls-14e2203ce5d7a6bbe050861a1206873a040674e3.tar.gz
build: write "FILE *fp" instead of "FILE *fd"tmp-fileio
This makes it clear that "fd" is not a file descriptor but a FILE pointer. Suggested by Tim Rühsen. Signed-off-by: Daiki Ueno <ueno@gnu.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/auth/psk_passwd.c12
-rw-r--r--lib/auth/srp_passwd.c22
-rw-r--r--lib/file.c8
-rw-r--r--lib/verify-tofu.c34
4 files changed, 38 insertions, 38 deletions
diff --git a/lib/auth/psk_passwd.c b/lib/auth/psk_passwd.c
index 7384703bc7..9a9d68c488 100644
--- a/lib/auth/psk_passwd.c
+++ b/lib/auth/psk_passwd.c
@@ -155,7 +155,7 @@ _gnutls_psk_pwd_find_entry(gnutls_session_t session,
gnutls_datum_t * psk)
{
gnutls_psk_server_credentials_t cred;
- FILE *fd;
+ FILE *fp;
char *line = NULL;
size_t line_size = 0;
int ret;
@@ -203,13 +203,13 @@ _gnutls_psk_pwd_find_entry(gnutls_session_t session,
/* Open the selected password file.
*/
- fd = fopen(cred->password_file, "re");
- if (fd == NULL) {
+ fp = fopen(cred->password_file, "re");
+ if (fp == NULL) {
gnutls_assert();
return GNUTLS_E_SRP_PWD_ERROR;
}
- while (getline(&line, &line_size, fd) > 0) {
+ while (getline(&line, &line_size, fp) > 0) {
if (username_matches(&username_datum, line, line_size)) {
ret = pwd_put_values(psk, line);
if (ret < 0) {
@@ -231,8 +231,8 @@ _gnutls_psk_pwd_find_entry(gnutls_session_t session,
ret = 0;
cleanup:
- if (fd != NULL)
- fclose(fd);
+ if (fp != NULL)
+ fclose(fp);
zeroize_key(line, line_size);
free(line);
diff --git a/lib/auth/srp_passwd.c b/lib/auth/srp_passwd.c
index 78848cdf10..49039a66e7 100644
--- a/lib/auth/srp_passwd.c
+++ b/lib/auth/srp_passwd.c
@@ -193,7 +193,7 @@ static int parse_tpasswd_conf_values(SRP_PWD_ENTRY * entry, char *str)
static int
pwd_read_conf(const char *pconf_file, SRP_PWD_ENTRY * entry, int idx)
{
- FILE *fd;
+ FILE *fp;
char *line = NULL;
size_t line_size = 0;
unsigned i, len;
@@ -202,14 +202,14 @@ pwd_read_conf(const char *pconf_file, SRP_PWD_ENTRY * entry, int idx)
snprintf(indexstr, sizeof(indexstr), "%u", (unsigned int) idx);
- fd = fopen(pconf_file, "re");
- if (fd == NULL) {
+ fp = fopen(pconf_file, "re");
+ if (fp == NULL) {
gnutls_assert();
return GNUTLS_E_FILE_ERROR;
}
len = strlen(indexstr);
- while (getline(&line, &line_size, fd) > 0) {
+ while (getline(&line, &line_size, fp) > 0) {
/* move to first ':' */
i = 0;
while ((i < line_size) && (line[i] != ':')
@@ -234,7 +234,7 @@ pwd_read_conf(const char *pconf_file, SRP_PWD_ENTRY * entry, int idx)
cleanup:
zeroize_key(line, line_size);
free(line);
- fclose(fd);
+ fclose(fp);
return ret;
}
@@ -244,7 +244,7 @@ _gnutls_srp_pwd_read_entry(gnutls_session_t state, char *username,
SRP_PWD_ENTRY ** _entry)
{
gnutls_srp_server_credentials_t cred;
- FILE *fd = NULL;
+ FILE *fp = NULL;
char *line = NULL;
size_t line_size = 0;
unsigned i, len;
@@ -308,15 +308,15 @@ _gnutls_srp_pwd_read_entry(gnutls_session_t state, char *username,
/* Open the selected password file.
*/
- fd = fopen(cred->password_file, "re");
- if (fd == NULL) {
+ fp = fopen(cred->password_file, "re");
+ if (fp == NULL) {
gnutls_assert();
ret = GNUTLS_E_SRP_PWD_ERROR;
goto cleanup;
}
len = strlen(username);
- while (getline(&line, &line_size, fd) > 0) {
+ while (getline(&line, &line_size, fp) > 0) {
/* move to first ':' */
i = 0;
while ((i < line_size) && (line[i] != '\0')
@@ -372,8 +372,8 @@ found:
zeroize_key(line, line_size);
free(line);
}
- if (fd)
- fclose(fd);
+ if (fp)
+ fclose(fp);
return ret;
}
diff --git a/lib/file.c b/lib/file.c
index ed044ff842..3ded84913b 100644
--- a/lib/file.c
+++ b/lib/file.c
@@ -27,13 +27,13 @@
int _gnutls_file_exists(const char *file)
{
- FILE *fd;
+ FILE *fp;
- fd = fopen(file, "re");
- if (fd == NULL)
+ fp = fopen(file, "re");
+ if (fp == NULL)
return -1;
- fclose(fd);
+ fclose(fp);
return 0;
}
diff --git a/lib/verify-tofu.c b/lib/verify-tofu.c
index 8baebaa011..5cedeed118 100644
--- a/lib/verify-tofu.c
+++ b/lib/verify-tofu.c
@@ -326,7 +326,7 @@ static int verify_pubkey(const char *file,
const char *host, const char *service,
const gnutls_datum_t * pubkey)
{
- FILE *fd;
+ FILE *fp;
char *line = NULL;
size_t line_size = 0;
int ret, l2, mismatch = 0;
@@ -343,14 +343,14 @@ static int verify_pubkey(const char *file,
if (service != NULL)
service_len = strlen(service);
- fd = fopen(file, "rbe");
- if (fd == NULL) {
+ fp = fopen(file, "rbe");
+ if (fp == NULL) {
ret = gnutls_assert_val(GNUTLS_E_FILE_ERROR);
goto cleanup;
}
do {
- l2 = getline(&line, &line_size, fd);
+ l2 = getline(&line, &line_size, fp);
if (l2 > 0) {
ret =
parse_line(line, host, host_len, service,
@@ -371,8 +371,8 @@ static int verify_pubkey(const char *file,
cleanup:
free(line);
- if (fd != NULL)
- fclose(fd);
+ if (fp != NULL)
+ fclose(fp);
gnutls_free(b64key.data);
return ret;
@@ -400,7 +400,7 @@ int store_pubkey(const char *db_name, const char *host,
const char *service, time_t expiration,
const gnutls_datum_t * pubkey)
{
- FILE *fd = NULL;
+ FILE *fp = NULL;
gnutls_datum_t b64key = { NULL, 0 };
int ret;
@@ -414,8 +414,8 @@ int store_pubkey(const char *db_name, const char *host,
goto cleanup;
}
- fd = fopen(db_name, "abe+");
- if (fd == NULL) {
+ fp = fopen(db_name, "abe+");
+ if (fp == NULL) {
ret = gnutls_assert_val(GNUTLS_E_FILE_ERROR);
goto cleanup;
}
@@ -425,14 +425,14 @@ int store_pubkey(const char *db_name, const char *host,
if (host == NULL)
host = "*";
- fprintf(fd, "|g0|%s|%s|%lu|%.*s\n", host, service,
+ fprintf(fp, "|g0|%s|%s|%lu|%.*s\n", host, service,
(unsigned long) expiration, b64key.size, b64key.data);
ret = 0;
cleanup:
- if (fd != NULL)
- fclose(fd);
+ if (fp != NULL)
+ fclose(fp);
gnutls_mutex_unlock(&_gnutls_file_mutex);
gnutls_free(b64key.data);
@@ -446,11 +446,11 @@ int store_commitment(const char *db_name, const char *host,
gnutls_digest_algorithm_t hash_algo,
const gnutls_datum_t * hash)
{
- FILE *fd;
+ FILE *fp;
char buffer[MAX_HASH_SIZE * 2 + 1];
- fd = fopen(db_name, "abe+");
- if (fd == NULL)
+ fp = fopen(db_name, "abe+");
+ if (fp == NULL)
return gnutls_assert_val(GNUTLS_E_FILE_ERROR);
if (service == NULL)
@@ -458,12 +458,12 @@ int store_commitment(const char *db_name, const char *host,
if (host == NULL)
host = "*";
- fprintf(fd, "|c0|%s|%s|%lu|%u|%s\n", host, service,
+ fprintf(fp, "|c0|%s|%s|%lu|%u|%s\n", host, service,
(unsigned long) expiration, (unsigned) hash_algo,
_gnutls_bin2hex(hash->data, hash->size, buffer,
sizeof(buffer), NULL));
- fclose(fd);
+ fclose(fp);
return 0;
}