From: Jordan Lee Date: Sat, 13 Apr 2013 18:29:56 +0000 (+0000) Subject: (trunk libT) #5316 'UMR in quark, tr-getopt code': fixed. X-Git-Tag: 2.80~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f1d616d37c24edcce32769a865411620523d12bf;p=transmission (trunk libT) #5316 'UMR in quark, tr-getopt code': fixed. --- diff --git a/libtransmission/quark.c b/libtransmission/quark.c index f0381156d..dbd7f9de5 100644 --- a/libtransmission/quark.c +++ b/libtransmission/quark.c @@ -399,7 +399,7 @@ compareKeys (const void * va, const void * vb) const struct tr_key_struct * a = va; const struct tr_key_struct * b = vb; - ret = memcmp (a->str, b->str, a->len); + ret = memcmp (a->str, b->str, MIN (a->len, b->len)); if (!ret && (a->len != b->len)) ret = a->len < b->len ? -1 : 1; diff --git a/libtransmission/tr-getopt.c b/libtransmission/tr-getopt.c index 1734db332..b528034a2 100644 --- a/libtransmission/tr-getopt.c +++ b/libtransmission/tr-getopt.c @@ -149,8 +149,10 @@ findOption (const tr_option * opts, { size_t len = o->longName ? strlen (o->longName) : 0; - if ((matchlen < len) && !memcmp (str, "--", 2) - && !memcmp (str + 2, o->longName, len) + if ((matchlen < len) + && (str[0] == '-') + && (str[1] == '-') + && !strncmp (str+2, o->longName, len) && (str[len + 2] == '\0' || (o->has_arg && str[len + 2] == '='))) { matchlen = len; @@ -160,8 +162,9 @@ findOption (const tr_option * opts, len = o->shortName ? strlen (o->shortName) : 0; - if ((matchlen < len) && !memcmp (str, "-", 1) - && !memcmp (str + 1, o->shortName, len) + if ((matchlen < len) + && (str[0] == '-') + && !strncmp (str+1, o->shortName, len) && (str[len + 1] == '\0' || o->has_arg)) { matchlen = len;