[Pkg-privacy-commits] [libotr] 34/225: Allowed passing NULL to the new FILEp functions. Open all files in binary mode (on Win32).
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:44:49 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository libotr.
commit 38035d0d9240a814b88fd9c499433e4316494a06
Author: cypherpunk <cypherpunk>
Date: Mon Jul 24 14:26:05 2006 +0000
Allowed passing NULL to the new FILEp functions.
Open all files in binary mode (on Win32).
---
src/privkey.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/privkey.c b/src/privkey.c
index 789ec6a..d1adaf0 100644
--- a/src/privkey.c
+++ b/src/privkey.c
@@ -187,6 +187,8 @@ gcry_error_t otrl_privkey_read_FILEp(OtrlUserState us, FILE *privf)
gcry_sexp_t allkeys;
size_t i;
+ if (!privf) return gcry_error(GPG_ERR_NO_ERROR);
+
/* Release any old ideas we had about our keys */
otrl_privkey_forget_all(us);
@@ -379,7 +381,7 @@ gcry_error_t otrl_privkey_generate(OtrlUserState us, const char *filename,
#ifndef WIN32
oldmask = umask(077);
#endif
- privf = fopen(filename, "w+");
+ privf = fopen(filename, "w+b");
if (!privf) {
#ifndef WIN32
umask(oldmask);
@@ -409,6 +411,8 @@ gcry_error_t otrl_privkey_generate_FILEp(OtrlUserState us, FILE *privf,
static const char *parmstr = "(genkey (dsa (nbits 4:1024)))";
OtrlPrivKey *p;
+ if (!privf) return gcry_error(GPG_ERR_NO_ERROR);
+
/* Create a DSA key */
err = gcry_sexp_new(&parms, parmstr, strlen(parmstr), 0);
if (err) {
@@ -465,7 +469,7 @@ gcry_error_t otrl_privkey_read_fingerprints(OtrlUserState us,
gcry_error_t err;
FILE *storef;
- storef = fopen(filename, "r");
+ storef = fopen(filename, "rb");
if (!storef) {
err = gcry_error_from_errno(errno);
return err;
@@ -490,6 +494,8 @@ gcry_error_t otrl_privkey_read_fingerprints_FILEp(OtrlUserState us,
unsigned char fingerprint[20];
size_t maxsize = sizeof(storeline);
+ if (!storef) return gcry_error(GPG_ERR_NO_ERROR);
+
while(fgets(storeline, maxsize, storef)) {
char *username;
char *accountname;
@@ -556,7 +562,7 @@ gcry_error_t otrl_privkey_write_fingerprints(OtrlUserState us,
gcry_error_t err;
FILE *storef;
- storef = fopen(filename, "w");
+ storef = fopen(filename, "wb");
if (!storef) {
err = gcry_error_from_errno(errno);
return err;
@@ -576,6 +582,8 @@ gcry_error_t otrl_privkey_write_fingerprints_FILEp(OtrlUserState us,
ConnContext *context;
Fingerprint *fprint;
+ if (!storef) return gcry_error(GPG_ERR_NO_ERROR);
+
for(context = us->context_root; context; context = context->next) {
/* Don't both with the first (fingerprintless) entry. */
for (fprint = context->fingerprint_root.next; fprint;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libotr.git
More information about the Pkg-privacy-commits
mailing list