occtl: show ip bans may produce invalid JSON

The occctl --json show ip bans command can produce a malformed JSON. This occurs when a banned IP is followed by an unprintable ban entry (i.e., a known IP address with accumulated ban points that hasn't reached the ban threshold).

Example (note trailing comma):

# occtl --json show ip bans
[
  {
    "IP":  "11.222.33.44",
    "Since":  "2026-01-15 18:13",
    "_Since":  " 3m:31s",
    "Score":  44
  },
]

# occtl --json show ip bans | jq
parse error: Expected another array element at line 8, column 1

Existing code uses a loop index variable (i < rep->n_info-1) to decide when to print a comma separator between array elements. When an "unprintable" entry is encountered, the loop skips it with a continue statement. If the last iterable entries are skipped this way, the final printed element ends with a trailing comma, and no subsequent element is printed without a separator - leaving invalid JSON.

Confirmed in 1.3.0 and 1.4.0; earlier versions are likely also affected.

I will work on a patch to resolve it.

Assignee Loading
Time tracking Loading