]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http-json: fix coverity warning
authorVictor Julien <victor@inliniac.net>
Fri, 2 May 2014 15:11:10 +0000 (17:11 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 2 May 2014 15:11:10 +0000 (17:11 +0200)
*** CID 1211009:  Bad bit shift operation  (BAD_SHIFT)
/src/output-json-http.c: 265 in JsonHttpLogJSON()
259         /* log custom fields if configured */
260         if (http_ctx->fields != 0)
261         {
262             HttpField f;
263             for (f = HTTP_FIELD_ACCEPT; f < HTTP_FIELD_SIZE; f++)
264             {
>>>     CID 1211009:  Bad bit shift operation  (BAD_SHIFT)
>>>     In expression "1 << f", left shifting by more than 31 bits has undefined behavior.  The shift amount, "f", is as much as 46.
265                 if ((http_ctx->fields & (1<<f)) != 0)
266                 {
267                     /* prevent logging a field twice if extended logging is
268                        enabled */
269                     if (((http_ctx->flags & LOG_HTTP_EXTENDED) == 0) ||
270                         ((http_ctx->flags & LOG_HTTP_EXTENDED) !=

________________________________________________________________________________________________________
*** CID 1211010:  Bad bit shift operation  (BAD_SHIFT)
/src/output-json-http.c: 492 in OutputHttpLogInitSub()
486                         {
487                             if ((strcmp(http_fields[f].config_field,
488                                        field->val) == 0) ||
489                                 (strcasecmp(http_fields[f].htp_field,
490                                             field->val) == 0))
491                             {
>>>     CID 1211010:  Bad bit shift operation  (BAD_SHIFT)
>>>     In expression "1 << f", left shifting by more than 31 bits has undefined behavior.  The shift amount, "f", is as much as 46.
492                                 http_ctx->fields |= (1<<f);
493                                 break;
494                             }
495                         }
496                     }
497                 }

src/output-json-http.c

index 2300742073029ae0846ed430b9a172c29edb618a..a9519b0e6e798206fc40e4aaa11bea498139fdd1 100644 (file)
@@ -262,7 +262,7 @@ static void JsonHttpLogJSON(JsonHttpLogThread *aft, json_t *js, htp_tx_t *tx)
         HttpField f;
         for (f = HTTP_FIELD_ACCEPT; f < HTTP_FIELD_SIZE; f++)
         {
-            if ((http_ctx->fields & (1<<f)) != 0)
+            if ((http_ctx->fields & (1ULL<<f)) != 0)
             {
                 /* prevent logging a field twice if extended logging is
                    enabled */
@@ -489,7 +489,7 @@ OutputCtx *OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
                             (strcasecmp(http_fields[f].htp_field,
                                         field->val) == 0))
                         {
-                            http_ctx->fields |= (1<<f);
+                            http_ctx->fields |= (1ULL<<f);
                             break;
                         }
                     }