]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
build: write "FILE *fp" instead of "FILE *fd"
authorDaiki Ueno <ueno@gnu.org>
Sat, 30 May 2020 09:06:57 +0000 (11:06 +0200)
committerDaiki Ueno <ueno@gnu.org>
Sat, 30 May 2020 09:10:12 +0000 (11:10 +0200)
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>
doc/examples/ex-pkcs12.c
lib/auth/psk_passwd.c
lib/auth/srp_passwd.c
lib/file.c
lib/verify-tofu.c
src/certtool-common.c
src/psk.c
src/serv.c
src/srptool.c
tests/srp.c

index 7890518f9475863f587269ea4d7c3e0e694e1549..0e2b64ee1cdbe50ebc96b100636c4a657f90b71f 100644 (file)
@@ -28,7 +28,7 @@ write_pkcs12(const gnutls_datum_t * cert,
         gnutls_pkcs12_bag_t bag, key_bag;
         char pkcs12_struct[10 * 1024];
         size_t pkcs12_struct_size;
-        FILE *fd;
+        FILE *fp;
 
         /* A good idea might be to use gnutls_x509_privkey_get_key_id()
          * to obtain a unique ID.
@@ -116,13 +116,13 @@ write_pkcs12(const gnutls_datum_t * cert,
                 return 1;
         }
 
-        fd = fopen(OUTFILE, "w");
-        if (fd == NULL) {
+        fp = fopen(OUTFILE, "w");
+        if (fp == NULL) {
                 fprintf(stderr, "cannot open file\n");
                 return 1;
         }
-        fwrite(pkcs12_struct, 1, pkcs12_struct_size, fd);
-        fclose(fd);
+        fwrite(pkcs12_struct, 1, pkcs12_struct_size, fp);
+        fclose(fp);
 
         gnutls_pkcs12_bag_deinit(bag);
         gnutls_pkcs12_bag_deinit(key_bag);
index 7384703bc7450889f607fa617e01c97798405758..9a9d68c48877d99b67b1580192a686a05e679f54 100644 (file)
@@ -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);
index 78848cdf10c7c08faf5e0eea21475ca7e23484e6..49039a66e708a45fc7cfb009dde4f8dea7da274d 100644 (file)
@@ -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;
 }
 
index ed044ff842732cdc2f10eb0bad504eb797f4f13e..3ded84913b92f6e96f1e7bf6991fab758e1b8983 100644 (file)
 
 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;
 }
 
index 8baebaa01186bda761c27ec88e9f0ec94c4d84ab..5cedeed1184fd803061b1743290b56255d06ea8c 100644 (file)
@@ -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;
 }
index ade6b1b569feb9b4529ea7b4393f3cee330f2d80..3af2d0808005d553c7b919ff9eb0b463711a7d6c 100644 (file)
@@ -389,7 +389,7 @@ gnutls_x509_crt_t load_cert(int mand, common_info_st * info)
 gnutls_x509_crt_t *load_cert_list(int mand, size_t * crt_size,
                                  common_info_st * info)
 {
-       FILE *fd;
+       FILE *fp;
        static gnutls_x509_crt_t *crt;
        int ret;
        gnutls_datum_t dat;
@@ -409,18 +409,18 @@ gnutls_x509_crt_t *load_cert_list(int mand, size_t * crt_size,
                        return NULL;
        }
 
-       fd = fopen(info->cert, "r");
-       if (fd == NULL) {
+       fp = fopen(info->cert, "r");
+       if (fp == NULL) {
                fprintf(stderr, "Could not open %s\n", info->cert);
                app_exit(1);
        }
 
-       fix_lbuffer(file_size(fd));
+       fix_lbuffer(file_size(fp));
 
-       size = fread(lbuffer, 1, lbuffer_size - 1, fd);
+       size = fread(lbuffer, 1, lbuffer_size - 1, fp);
        lbuffer[size] = 0;
 
-       fclose(fd);
+       fclose(fp);
 
        dat.data = (void *) lbuffer;
        dat.size = size;
@@ -448,7 +448,7 @@ gnutls_x509_crt_t *load_cert_list(int mand, size_t * crt_size,
 gnutls_x509_crl_t *load_crl_list(int mand, size_t * crl_size,
                                  common_info_st * info)
 {
-       FILE *fd;
+       FILE *fp;
        static gnutls_x509_crl_t *crl;
        unsigned int crl_max;
        int ret;
@@ -467,18 +467,18 @@ gnutls_x509_crl_t *load_crl_list(int mand, size_t * crl_size,
                        return NULL;
        }
 
-       fd = fopen(info->crl, "r");
-       if (fd == NULL) {
+       fp = fopen(info->crl, "r");
+       if (fp == NULL) {
                fprintf(stderr, "Could not open %s\n", info->crl);
                app_exit(1);
        }
 
-       fix_lbuffer(file_size(fd));
+       fix_lbuffer(file_size(fp));
 
-       size = fread(lbuffer, 1, lbuffer_size - 1, fd);
+       size = fread(lbuffer, 1, lbuffer_size - 1, fp);
        lbuffer[size] = 0;
 
-       fclose(fd);
+       fclose(fp);
 
        dat.data = (void *) lbuffer;
        dat.size = size;
index 775d8f80c93f4767a21c6a5c063d725d36c94412..6f77c6f285fe3956711b4df2229a629ccbf2a268 100644 (file)
--- a/src/psk.c
+++ b/src/psk.c
@@ -141,35 +141,35 @@ int main(int argc, char **argv)
 
 static int filecopy(const char *src, const char *dst)
 {
-       FILE *fd, *fd2;
+       FILE *fp, *fp2;
        char line[5 * 1024];
        char *p;
 
-       fd = fopen(dst, "w");
-       if (fd == NULL) {
+       fp = fopen(dst, "w");
+       if (fp == NULL) {
                fprintf(stderr, "Cannot open '%s' for write\n", dst);
                return -1;
        }
 
-       fd2 = fopen(src, "r");
-       if (fd2 == NULL) {
+       fp2 = fopen(src, "r");
+       if (fp2 == NULL) {
                /* empty file */
-               fclose(fd);
+               fclose(fp);
                return 0;
        }
 
        line[sizeof(line) - 1] = 0;
        do {
-               p = fgets(line, sizeof(line) - 1, fd2);
+               p = fgets(line, sizeof(line) - 1, fp2);
                if (p == NULL)
                        break;
 
-               fputs(line, fd);
+               fputs(line, fp);
        }
        while (1);
 
-       fclose(fd);
-       fclose(fd2);
+       fclose(fp);
+       fclose(fp2);
 
        return 0;
 }
@@ -178,7 +178,7 @@ static int
 write_key(const char *username, const char *key, int key_size,
          const char *passwd_file)
 {
-       FILE *fd;
+       FILE *fp;
        char line[5 * 1024];
        char *p, *pp;
        char tmpname[1024];
@@ -186,7 +186,7 @@ write_key(const char *username, const char *key, int key_size,
 
        /* delete previous entry */
        struct stat st;
-       FILE *fd2;
+       FILE *fp2;
        int put;
 
        if (strlen(passwd_file) + 5 > sizeof(tmpname)) {
@@ -207,25 +207,25 @@ write_key(const char *username, const char *key, int key_size,
                return -1;
        }
 
-       fd = fopen(passwd_file, "w");
-       if (fd == NULL) {
+       fp = fopen(passwd_file, "w");
+       if (fp == NULL) {
                fprintf(stderr, "Cannot open '%s' for write\n",
                        passwd_file);
                (void)remove(tmpname);
                return -1;
        }
 
-       fd2 = fopen(tmpname, "r");
-       if (fd2 == NULL) {
+       fp2 = fopen(tmpname, "r");
+       if (fp2 == NULL) {
                fprintf(stderr, "Cannot open '%s' for read\n", tmpname);
                (void)remove(tmpname);
-               fclose(fd);
+               fclose(fp);
                return -1;
        }
 
        put = 0;
        do {
-               p = fgets(line, sizeof(line) - 1, fd2);
+               p = fgets(line, sizeof(line) - 1, fp2);
                if (p == NULL)
                        break;
 
@@ -237,19 +237,19 @@ write_key(const char *username, const char *key, int key_size,
                            MAX(strlen(username),
                                (unsigned int) (pp - p))) == 0) {
                        put = 1;
-                       fprintf(fd, "%s:%s\n", username, key);
+                       fprintf(fp, "%s:%s\n", username, key);
                } else {
-                       fputs(line, fd);
+                       fputs(line, fp);
                }
        }
        while (1);
 
        if (put == 0) {
-               fprintf(fd, "%s:%s\n", username, key);
+               fprintf(fp, "%s:%s\n", username, key);
        }
 
-       fclose(fd);
-       fclose(fd2);
+       fclose(fp);
+       fclose(fp2);
 
        (void)remove(tmpname);
 
index 414cd0546b3cf1374f171cda0a0dfd9b4fc28001..57304bc9d3bbb7e1c79b02c501c25e990ed35dc1 100644 (file)
@@ -219,7 +219,7 @@ static void read_dh_params(void)
        char tmpdata[2048];
        int size;
        gnutls_datum_t params;
-       FILE *fd;
+       FILE *fp;
 
        if (gnutls_dh_params_init(&dh_params) < 0) {
                fprintf(stderr, "Error in dh parameter initialization\n");
@@ -228,15 +228,15 @@ static void read_dh_params(void)
 
        /* read the params file
         */
-       fd = fopen(dh_params_file, "r");
-       if (fd == NULL) {
+       fp = fopen(dh_params_file, "r");
+       if (fp == NULL) {
                fprintf(stderr, "Could not open %s\n", dh_params_file);
                exit(1);
        }
 
-       size = fread(tmpdata, 1, sizeof(tmpdata) - 1, fd);
+       size = fread(tmpdata, 1, sizeof(tmpdata) - 1, fp);
        tmpdata[size] = 0;
-       fclose(fd);
+       fclose(fp);
 
        params.data = (unsigned char *) tmpdata;
        params.size = size;
index 27821be238d41b283b34217f8397ac4018ee27d0..7939f6bfabc007694cc91d4f9eafdb615e82bb06 100644 (file)
@@ -74,14 +74,14 @@ static void print_num(const char *msg, const gnutls_datum_t * num)
 
 static int generate_create_conf(const char *tpasswd_conf)
 {
-       FILE *fd;
+       FILE *fp;
        char line[5 * 1024];
        int index = 1, srp_idx;
        gnutls_datum_t g, n;
        gnutls_datum_t str_g, str_n;
 
-       fd = fopen(tpasswd_conf, "w");
-       if (fd == NULL) {
+       fp = fopen(tpasswd_conf, "w");
+       if (fp == NULL) {
                fprintf(stderr, "Cannot open file '%s'\n", tpasswd_conf);
                return -1;
        }
@@ -119,13 +119,13 @@ static int generate_create_conf(const char *tpasswd_conf)
 
                if (gnutls_srp_base64_encode_alloc(&n, &str_n) < 0) {
                        fprintf(stderr, "Could not encode\n");
-                       fclose(fd);
+                       fclose(fp);
                        return -1;
                }
 
                if (gnutls_srp_base64_encode_alloc(&g, &str_g) < 0) {
                        fprintf(stderr, "Could not encode\n");
-                       fclose(fd);
+                       fclose(fp);
                        return -1;
                }
 
@@ -134,11 +134,11 @@ static int generate_create_conf(const char *tpasswd_conf)
                gnutls_free(str_n.data);
                gnutls_free(str_g.data);
 
-               fwrite(line, 1, strlen(line), fd);
+               fwrite(line, 1, strlen(line), fp);
 
        }
 
-       fclose(fd);
+       fclose(fp);
 
        return 0;
 
@@ -211,35 +211,35 @@ _verify_passwd_int(const char *username, const char *passwd,
 
 static int filecopy(const char *src, const char *dst)
 {
-       FILE *fd, *fd2;
+       FILE *fp, *fp2;
        char line[5 * 1024];
        char *p;
 
-       fd = fopen(dst, "w");
-       if (fd == NULL) {
+       fp = fopen(dst, "w");
+       if (fp == NULL) {
                fprintf(stderr, "Cannot open '%s' for write\n", dst);
                return -1;
        }
 
-       fd2 = fopen(src, "r");
-       if (fd2 == NULL) {
+       fp2 = fopen(src, "r");
+       if (fp2 == NULL) {
                /* empty file */
-               fclose(fd);
+               fclose(fp);
                return 0;
        }
 
        line[sizeof(line) - 1] = 0;
        do {
-               p = fgets(line, sizeof(line) - 1, fd2);
+               p = fgets(line, sizeof(line) - 1, fp2);
                if (p == NULL)
                        break;
 
-               fputs(line, fd);
+               fputs(line, fp);
        }
        while (1);
 
-       fclose(fd);
-       fclose(fd2);
+       fclose(fp);
+       fclose(fp2);
 
        return 0;
 }
@@ -247,18 +247,18 @@ static int filecopy(const char *src, const char *dst)
 /* accepts password file */
 static int find_strchr(const char *username, const char *file)
 {
-       FILE *fd;
+       FILE *fp;
        char *pos;
        char line[5 * 1024];
        unsigned int i;
 
-       fd = fopen(file, "r");
-       if (fd == NULL) {
+       fp = fopen(file, "r");
+       if (fp == NULL) {
                fprintf(stderr, "Cannot open file '%s'\n", file);
                return -1;
        }
 
-       while (fgets(line, sizeof(line), fd) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
                /* move to first ':' */
                i = 0;
                while ((line[i] != ':') && (line[i] != '\0')
@@ -269,12 +269,12 @@ static int find_strchr(const char *username, const char *file)
                        /* find the index */
                        pos = strrchr(line, ':');
                        pos++;
-                       fclose(fd);
+                       fclose(fp);
                        return atoi(pos);
                }
        }
 
-       fclose(fd);
+       fclose(fp);
        return -1;
 }
 
@@ -285,7 +285,7 @@ static int
 verify_passwd(const char *conffile, const char *tpasswd,
              const char *username, const char *passwd)
 {
-       FILE *fd;
+       FILE *fp;
        char line[5 * 1024];
        unsigned int i;
        gnutls_datum_t g, n;
@@ -299,14 +299,14 @@ verify_passwd(const char *conffile, const char *tpasswd,
                return -1;
        }
 
-       fd = fopen(conffile, "r");
-       if (fd == NULL) {
+       fp = fopen(conffile, "r");
+       if (fp == NULL) {
                fprintf(stderr, "Cannot find %s\n", conffile);
                return -1;
        }
 
        do {
-               p = fgets(line, sizeof(line) - 1, fd);
+               p = fgets(line, sizeof(line) - 1, fp);
        }
        while (p != NULL && atoi(p) != iindex);
 
@@ -316,20 +316,20 @@ verify_passwd(const char *conffile, const char *tpasswd,
        }
        line[sizeof(line) - 1] = 0;
 
-       fclose(fd);
+       fclose(fp);
 
        if ((iindex = read_conf_values(&g, &n, line)) < 0) {
                fprintf(stderr, "Cannot parse conf file '%s'\n", conffile);
                return -1;
        }
 
-       fd = fopen(tpasswd, "r");
-       if (fd == NULL) {
+       fp = fopen(tpasswd, "r");
+       if (fp == NULL) {
                fprintf(stderr, "Cannot open file '%s'\n", tpasswd);
                return -1;
        }
 
-       while (fgets(line, sizeof(line), fd) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
                /* move to first ':' 
                 * This is the actual verifier.
                 */
@@ -342,7 +342,7 @@ verify_passwd(const char *conffile, const char *tpasswd,
                        char *verifier_pos, *salt_pos;
 
                        pos = strchr(line, ':');
-                       fclose(fd);
+                       fclose(fp);
                        if (pos == NULL) {
                                fprintf(stderr,
                                        "Cannot parse conf file '%s'\n",
@@ -369,7 +369,7 @@ verify_passwd(const char *conffile, const char *tpasswd,
                }
        }
 
-       fclose(fd);
+       fclose(fp);
        return -1;
 
 }
@@ -511,7 +511,7 @@ int
 crypt_int(const char *username, const char *passwd, int salt_size,
          const char *tpasswd_conf, const char *tpasswd, int uindex)
 {
-       FILE *fd;
+       FILE *fp;
        char *cr;
        gnutls_datum_t g, n;
        char line[5 * 1024];
@@ -519,14 +519,14 @@ crypt_int(const char *username, const char *passwd, int salt_size,
        int iindex;
        char tmpname[1024];
 
-       fd = fopen(tpasswd_conf, "r");
-       if (fd == NULL) {
+       fp = fopen(tpasswd_conf, "r");
+       if (fp == NULL) {
                fprintf(stderr, "Cannot find %s\n", tpasswd_conf);
                return -1;
        }
 
        do {                    /* find the specified uindex in file */
-               p = fgets(line, sizeof(line) - 1, fd);
+               p = fgets(line, sizeof(line) - 1, fp);
        }
        while (p != NULL && (iindex = atoi(p)) != uindex);
 
@@ -536,7 +536,7 @@ crypt_int(const char *username, const char *passwd, int salt_size,
        }
        line[sizeof(line) - 1] = 0;
 
-       fclose(fd);
+       fclose(fp);
        if ((iindex = read_conf_values(&g, &n, line)) < 0) {
                fprintf(stderr, "Cannot parse conf file '%s'\n",
                        tpasswd_conf);
@@ -550,7 +550,7 @@ crypt_int(const char *username, const char *passwd, int salt_size,
        } else {
                /* delete previous entry */
                struct stat st;
-               FILE *fd2;
+               FILE *fp2;
                int put;
 
                if (strlen(tpasswd) + 5 > sizeof(tmpname)) {
@@ -572,16 +572,16 @@ crypt_int(const char *username, const char *passwd, int salt_size,
                        return -1;
                }
 
-               fd = fopen(tpasswd, "w");
-               if (fd == NULL) {
+               fp = fopen(tpasswd, "w");
+               if (fp == NULL) {
                        fprintf(stderr, "Cannot open '%s' for write\n",
                                tpasswd);
                        (void)remove(tmpname);
                        return -1;
                }
 
-               fd2 = fopen(tmpname, "r");
-               if (fd2 == NULL) {
+               fp2 = fopen(tmpname, "r");
+               if (fp2 == NULL) {
                        fprintf(stderr, "Cannot open '%s' for read\n",
                                tmpname);
                        (void)remove(tmpname);
@@ -590,7 +590,7 @@ crypt_int(const char *username, const char *passwd, int salt_size,
 
                put = 0;
                do {
-                       p = fgets(line, sizeof(line) - 1, fd2);
+                       p = fgets(line, sizeof(line) - 1, fp2);
                        if (p == NULL)
                                break;
 
@@ -602,20 +602,20 @@ crypt_int(const char *username, const char *passwd, int salt_size,
                                    MAX(strlen(username),
                                        (unsigned int) (pp - p))) == 0) {
                                put = 1;
-                               fprintf(fd, "%s:%s:%u\n", username, cr,
+                               fprintf(fp, "%s:%s:%u\n", username, cr,
                                        iindex);
                        } else {
-                               fputs(line, fd);
+                               fputs(line, fp);
                        }
                }
                while (1);
 
                if (put == 0) {
-                       fprintf(fd, "%s:%s:%u\n", username, cr, iindex);
+                       fprintf(fp, "%s:%s:%u\n", username, cr, iindex);
                }
 
-               fclose(fd);
-               fclose(fd2);
+               fclose(fp);
+               fclose(fp2);
 
                (void)remove(tmpname);
 
index c927e877be145b105e5b3336269bfb7fd95cb171..607e52ae46e7c23ff339fc588996291012fa1461 100644 (file)
@@ -329,21 +329,21 @@ const char *tpasswd_conf_file =
 
 void doit(void)
 {
-       FILE *fd;
+       FILE *fp;
 
-       fd = fopen("tpasswd.conf", "w");
-       if (fd == NULL)
+       fp = fopen("tpasswd.conf", "w");
+       if (fp == NULL)
                exit(1);
 
-       fwrite(tpasswd_conf_file, 1, strlen(tpasswd_conf_file), fd);
-       fclose(fd);
+       fwrite(tpasswd_conf_file, 1, strlen(tpasswd_conf_file), fp);
+       fclose(fp);
 
-       fd = fopen("tpasswd", "w");
-       if (fd == NULL)
+       fp = fopen("tpasswd", "w");
+       if (fp == NULL)
                exit(1);
 
-       fwrite(tpasswd_file, 1, strlen(tpasswd_file), fd);
-       fclose(fd);
+       fwrite(tpasswd_file, 1, strlen(tpasswd_file), fp);
+       fclose(fp);
 
        start("tls1.2 srp-1024", "NORMAL:-VERS-ALL:+VERS-TLS1.2:-KX-ALL:+SRP", "test", "test", 0);
        start("tls1.2 srp-1536", "NORMAL:-VERS-ALL:+VERS-TLS1.2:-KX-ALL:+SRP", "test2", "test2", 0);