cmd: Add explicit check for array bounds.