[Pkg-privacy-commits] [libotr] 02/225: * src/privkey.c (otrl_privkey_read_fingerprints): Allow fields, particularly accountnames, to contain spaces. Closes #1198379.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:44:43 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 519348916db2f8d6611456bfe783b65785891ff1
Author: cypherpunk <cypherpunk>
Date: Mon May 9 18:36:59 2005 +0000
* src/privkey.c (otrl_privkey_read_fingerprints): Allow fields,
particularly accountnames, to contain spaces. Closes #1198379.
---
ChangeLog | 5 +++++
src/privkey.c | 34 +++++++++++++++++++++++++++-------
2 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e38b42f..55bdc97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-05-09
+
+ * src/privkey.c (otrl_privkey_read_fingerprints): Allow fields,
+ particularly accountnames, to contain spaces. Closes #1198379.
+
2005-05-03
* README:
diff --git a/src/privkey.c b/src/privkey.c
index 828c90c..dc3b1d4 100644
--- a/src/privkey.c
+++ b/src/privkey.c
@@ -359,16 +359,36 @@ gcry_error_t otrl_privkey_read_fingerprints(OtrlUserState us,
return err;
}
while(fgets(storeline, maxsize, storef)) {
- char username[sizeof(storeline)];
- char accountname[sizeof(storeline)];
- char protocol[sizeof(storeline)];
- char hex[sizeof(storeline)];
+ char *username;
+ char *accountname;
+ char *protocol;
+ char *hex;
+ char *tab;
+ char *eol;
int res, i, j;
/* Parse the line, which should be of the form:
* username\taccountname\tprotocol\t40_hex_nybbles\n */
- res = sscanf(storeline, "%s %s %s %s", username, accountname,
- protocol, hex);
- if (res != 4) continue;
+ username = storeline;
+ tab = strchr(username, '\t');
+ if (!tab) continue;
+ *tab = '\0';
+
+ accountname = tab + 1;
+ tab = strchr(accountname, '\t');
+ if (!tab) continue;
+ *tab = '\0';
+
+ protocol = tab + 1;
+ tab = strchr(protocol, '\t');
+ if (!tab) continue;
+ *tab = '\0';
+
+ hex = tab + 1;
+ eol = strchr(hex, '\r');
+ if (!eol) eol = strchr(hex, '\n');
+ if (!eol) continue;
+ *eol = '\0';
+
if (strlen(hex) != 40) continue;
for(j=0, i=0; i<40; i+=2) {
fingerprint[j++] = (ctoh(hex[i]) << 4) + (ctoh(hex[i+1]));
--
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