From d6f5ec6f098f7f6b741bc3face1608c25b233caa Mon Sep 17 00:00:00 2001
From: "dejun.xdj" <dejun.xdj@alibaba-inc.com>
Date: Mon, 30 Jul 2018 21:32:07 +0800
Subject: [PATCH] Streams: add mmid_supp argument in streamParseIDOrReply().

If 'mmid_supp' is set to 0, "-" and "+" will be
treated as an invalid ID.
---
 src/t_stream.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/t_stream.c b/src/t_stream.c
index ea1290faf..8725542c9 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -1060,14 +1060,18 @@ int string2ull(const char *s, unsigned long long *value) {
  * form, just stating the milliseconds time part of the stream. In such a case
  * the missing part is set according to the value of 'missing_seq' parameter.
  * The IDs "-" and "+" specify respectively the minimum and maximum IDs
- * that can be represented.
+ * that can be represented. If 'mmid_supp' is set to 0, "-" and "+" will be
+ * treated as an invalid ID.
  *
  * If 'c' is set to NULL, no reply is sent to the client. */
-int streamParseIDOrReply(client *c, robj *o, streamID *id, uint64_t missing_seq) {
+int streamParseIDOrReply(client *c, robj *o, streamID *id, uint64_t missing_seq, int mmid_supp) {
     char buf[128];
     if (sdslen(o->ptr) > sizeof(buf)-1) goto invalid;
     memcpy(buf,o->ptr,sdslen(o->ptr)+1);
 
+    if (!mmid_supp && (buf[0] == '-' || buf[0] == '+') &&
+        buf[1] == '\0') goto invalid;
+
     /* Handle the "-" and "+" special cases. */
     if (buf[0] == '-' && buf[1] == '\0') {
         id->ms = 0;