[Pkg-privacy-commits] [irssi-plugin-otr] 164/267: Fix: utils pointer check and comments
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:39 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository irssi-plugin-otr.
commit ee3623c78f08c3130c6cec70b97c9f53bb5b4c12
Author: David Goulet <dgoulet at ev0ke.net>
Date: Sat Dec 1 21:11:41 2012 -0500
Fix: utils pointer check and comments
Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
src/utils.c | 34 +++++++++++++++++++++++++++++-----
src/utils.h | 2 +-
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/src/utils.c b/src/utils.c
index 35b221b..deca84c 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,7 +1,7 @@
/*
* Off-the-Record Messaging (OTR) modules for IRC
*
- * Copyright (C) 2008 Uli Meis <a.sporto+bee at gmail.com>
+ * Copyright (C) 2012 - David Goulet <dgoulet at ev0ke.net>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -64,13 +64,21 @@ char *utils_trim_string(char *s)
return rtrim(ltrim(s));
}
+/*
+ * Extract question and secret for an SMP authentication.
+ *
+ * Return 0 and set question/secret on success. Else, return negative value and
+ * params are untouched.
+ */
int utils_io_extract_smp(const char *data, char **question, char **secret)
{
unsigned int q_len, s_len;
const char *tmp, *q_end, *q_beg, *args = data;
char *q, *s;
- *question = *secret = NULL;
+ if (!data || !question || !secret) {
+ goto error;
+ }
/* Check for '[' as first char */
q_beg = strchr(args, '[');
@@ -177,12 +185,17 @@ error:
return -1;
}
+/*
+ * Set _argv and _argc from the string in _data.
+ *
+ * On error, argv is untouched argc set to 0.
+ */
void utils_explode_args(const char *_data, char ***_argv, int *_argc)
{
int argc = 0, i = 0, have_arg = 0;
char **argv = NULL, *c, *data = NULL, *cmd_offset;
- if (!_data) {
+ if (!_data || !_argv || !_argc) {
goto error;
}
@@ -235,14 +248,17 @@ void utils_explode_args(const char *_data, char ***_argv, int *_argc)
i++;
}
-error:
*_argv = argv;
- *_argc = argc;
+error:
+ *_argc = argc;
free(data);
return;
}
+/*
+ * Free an argv array. Usually, call this after using utils_explode_args.
+ */
void utils_free_args(char ***argv, int argc)
{
int i;
@@ -261,6 +277,11 @@ void utils_free_args(char ***argv, int argc)
free(args);
}
+/*
+ * Extract otr command from an irssi command string.
+ *
+ * Ex: /otr auth my_secret, _cmd is set to "auth"
+ */
void utils_extract_command(const char *data, char **_cmd)
{
char *s, *cmd = NULL;
@@ -285,6 +306,9 @@ error:
return;
}
+/*
+ * String to uppercase. Done inplace!
+ */
void utils_string_to_upper(char *string)
{
int i = 0;
diff --git a/src/utils.h b/src/utils.h
index 019e399..9a8727c 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1,7 +1,7 @@
/*
* Off-the-Record Messaging (OTR) modules for IRC
*
- * Copyright (C) 2008 Uli Meis <a.sporto+bee at gmail.com>
+ * Copyright (C) 2012 - David Goulet <dgoulet at ev0ke.net>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git
More information about the Pkg-privacy-commits
mailing list