[gmime] minor fixups thanks to coverity scan
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime] minor fixups thanks to coverity scan
- Date: Wed, 20 Dec 2017 17:13:20 +0000 (UTC)
commit 14de8abf360b807603e4f7b537ff0dab26273be6
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date: Mon Dec 18 09:07:30 2017 -0500
minor fixups thanks to coverity scan
TODO | 7 ++++++-
gmime/gmime-autocrypt.c | 12 ++++++------
gmime/gmime-filter-openpgp.c | 16 +++++++++++-----
gmime/gmime-version.h.in | 10 +++++-----
4 files changed, 28 insertions(+), 17 deletions(-)
---
diff --git a/TODO b/TODO
index c235b9d..bfd4bd3 100644
--- a/TODO
+++ b/TODO
@@ -3,9 +3,14 @@ the GMime library. This list of tasks in no way indicates priority,
that is to say that there is no rhyme or reason to the order that the
tasks are presented in.
-GMime 3.0 Planning:
+GMime 4.0 Planning:
===================
+- Remove g_mime_stream_close()
+
+- Remove g_mime_stream_filter_get/set_owner() - these will no longer
+ be necessary once close() is removed.
+
- Rename g_mime_message_[get,set]_mime_part() to g_mime_message_[get,set]_body()?
This would require me to rename g_mime_message_get_body() to
g_mime_message_get_text_body()?
diff --git a/gmime/gmime-autocrypt.c b/gmime/gmime-autocrypt.c
index e13b727..de10dd1 100644
--- a/gmime/gmime-autocrypt.c
+++ b/gmime/gmime-autocrypt.c
@@ -139,9 +139,10 @@ GMimeAutocryptHeader *
g_mime_autocrypt_header_new_from_string (const char *string)
{
GMimeAutocryptHeader *ret = NULL;
+ GBytes *newkeydata = NULL;
gchar **ksplit = NULL;
gchar *kjoined = NULL;
- GBytes *newkeydata = NULL;
+
if (string == NULL)
return NULL;
@@ -149,7 +150,7 @@ g_mime_autocrypt_header_new_from_string (const char *string)
both of which might happen to mails in transit. So this
could be improved. It's also probably not currently the
most efficient implementation. */
-
+
struct _attr { char *val; const char *name; size_t sz; int count; };
#define attr(n, str) struct _attr n = { .name = str, .sz = sizeof(str)-1 }
attr(k, "keydata");
@@ -182,7 +183,7 @@ g_mime_autocrypt_header_new_from_string (const char *string)
}
}
-
+
if (k.count != 1)
goto done;
if (a.count != 1)
@@ -190,7 +191,7 @@ g_mime_autocrypt_header_new_from_string (const char *string)
if (p.count > 1)
goto done;
GMimeAutocryptPreferEncrypt newpref = GMIME_AUTOCRYPT_PREFER_ENCRYPT_NONE;
-
+
if (p.count && (g_ascii_strcasecmp ("mutual", p.val) == 0))
newpref = GMIME_AUTOCRYPT_PREFER_ENCRYPT_MUTUAL;
@@ -206,8 +207,7 @@ g_mime_autocrypt_header_new_from_string (const char *string)
g_mime_autocrypt_header_set_keydata (ret, newkeydata);
done:
- if (vals)
- g_strfreev (vals);
+ g_strfreev (vals);
if (ksplit)
g_strfreev (ksplit);
if (newkeydata)
diff --git a/gmime/gmime-filter-openpgp.c b/gmime/gmime-filter-openpgp.c
index 2feaba8..374d2c3 100644
--- a/gmime/gmime-filter-openpgp.c
+++ b/gmime/gmime-filter-openpgp.c
@@ -47,6 +47,8 @@ const GMimeOpenPGPMarker g_mime_openpgp_markers[9] = {
{ "-----END PGP PRIVATE KEY BLOCK-----", 35, GMIME_OPENPGP_BEGIN_PGP_PRIVATE_KEY_BLOCK,
GMIME_OPENPGP_END_PGP_PRIVATE_KEY_BLOCK, TRUE }
};
+#define NUM_OPENPGP_MARKERS G_N_ELEMENTS (g_mime_openpgp_markers)
+
static void g_mime_filter_openpgp_class_init (GMimeFilterOpenPGPClass *klass);
static void g_mime_filter_openpgp_init (GMimeFilterOpenPGP *filter, GMimeFilterOpenPGPClass *klass);
@@ -227,7 +229,7 @@ scan (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
if (inptr == inend) {
gboolean partial = FALSE;
- for (i = 0; i < G_N_ELEMENTS (g_mime_openpgp_markers); i++) {
+ for (i = 0; i < NUM_OPENPGP_MARKERS; i++) {
if (g_mime_openpgp_markers[i].before == openpgp->state &&
is_partial_match (lineptr, inend, &g_mime_openpgp_markers[i])) {
partial = TRUE;
break;
@@ -247,13 +249,16 @@ scan (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
inptr++;
- for (i = 0; i < G_N_ELEMENTS (g_mime_openpgp_markers); i++) {
+ for (i = 0; i < NUM_OPENPGP_MARKERS; i++) {
if (g_mime_openpgp_markers[i].before == openpgp->state && is_marker (lineptr,
inend, &g_mime_openpgp_markers[i], &cr)) {
openpgp->state = g_mime_openpgp_markers[i].after;
set_position (openpgp, lineptr - inbuf, i, cr);
*outbuf = (char *) lineptr;
*outlen = inptr - lineptr;
- openpgp->next = i + 1;
+
+ if (!g_mime_openpgp_markers[i].is_end_marker)
+ openpgp->next = i + 1;
+
break;
}
}
@@ -264,7 +269,7 @@ scan (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
return;
}
}
-
+
do {
const char *lineptr = inptr;
@@ -298,10 +303,11 @@ scan (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
openpgp->seen_end_marker = g_mime_openpgp_markers[openpgp->next].is_end_marker;
openpgp->state = g_mime_openpgp_markers[openpgp->next].after;
set_position (openpgp, lineptr - inbuf, openpgp->next, cr);
- openpgp->next++;
if (openpgp->seen_end_marker)
break;
+
+ openpgp->next++;
}
} while (inptr < inend);
diff --git a/gmime/gmime-version.h.in b/gmime/gmime-version.h.in
index 5c5a785..839b30b 100644
--- a/gmime/gmime-version.h.in
+++ b/gmime/gmime-version.h.in
@@ -27,35 +27,35 @@
*
* GMime's major version.
**/
-#define GMIME_MAJOR_VERSION (@GMIME_MAJOR_VERSION@)
+#define GMIME_MAJOR_VERSION (@GMIME_MAJOR_VERSION@U)
/**
* GMIME_MINOR_VERSION:
*
* GMime's minor version.
**/
-#define GMIME_MINOR_VERSION (@GMIME_MINOR_VERSION@)
+#define GMIME_MINOR_VERSION (@GMIME_MINOR_VERSION@U)
/**
* GMIME_MICRO_VERSION:
*
* GMime's micro version.
**/
-#define GMIME_MICRO_VERSION (@GMIME_MICRO_VERSION@)
+#define GMIME_MICRO_VERSION (@GMIME_MICRO_VERSION@U)
/**
* GMIME_BINARY_AGE:
*
* GMime's binary age.
**/
-#define GMIME_BINARY_AGE (@GMIME_BINARY_AGE@)
+#define GMIME_BINARY_AGE (@GMIME_BINARY_AGE@U)
/**
* GMIME_INTERFACE_AGE:
*
* GMime's interface age.
**/
-#define GMIME_INTERFACE_AGE (@GMIME_INTERFACE_AGE@)
+#define GMIME_INTERFACE_AGE (@GMIME_INTERFACE_AGE@U)
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]