k3s/pkg/util
Kubernetes Submit Queue 36c20d1f5e Merge pull request #38525 from juanvallejo/jvallejo/fix-panic-on-invalid-json-syntax
Automatic merge from submit-queue (batch tested with PRs 38525, 38977)

Prevent json decoder panic on invalid input

Related downstream issue: https://github.com/openshift/origin/issues/12132
```
# Can be replicated on kubectl with:
$ cat panic.json
{
  "kind": "Pod",
  "apiVersion": "v1",
  "metadata": {
    "name": "",
    "labels": {
      "name": ""
    },
    "generateName": "",
    "namespace": "",
    "annotations": []
  },
  "spec": {}
},

$ kubectl create -f panic.json --validate=false
```

**Release note**:
```release-note
release-note-none
```

This patch handles cases where `ioutil.ReadAll` will return a single
character output on an invalid json input, causing the `Decode` method
to panic when it tries to calculate the line number for the syntax
error. The example below would cause a panic due to the trailing comma
at the end:

```
{
  "kind": "Pod",
  "apiVersion": "v1",
  "metadata": {
    "name": "",
    "labels": {
      "name": ""
    },
    "generateName": "",
    "namespace": "",
    "annotations": []
  },
  "spec": {}
},
```

@kubernetes/cli-review @fabianofranz
2016-12-19 13:23:03 -08:00
..
async autoupdate BUILD files 2016-12-12 13:30:07 -08:00
bandwidth autoupdate BUILD files 2016-12-12 13:30:07 -08:00
cache autoupdate BUILD files 2016-12-12 13:30:07 -08:00
cert autoupdate BUILD files 2016-12-12 13:30:07 -08:00
chmod autoupdate BUILD files 2016-12-12 13:30:07 -08:00
chown autoupdate BUILD files 2016-12-12 13:30:07 -08:00
clock autoupdate BUILD files 2016-12-12 13:30:07 -08:00
config autoupdate BUILD files 2016-12-12 13:30:07 -08:00
configz autoupdate BUILD files 2016-12-12 13:30:07 -08:00
crlf autoupdate BUILD files 2016-12-12 13:30:07 -08:00
dbus autoupdate BUILD files 2016-12-12 13:30:07 -08:00
diff autoupdate BUILD files 2016-12-12 13:30:07 -08:00
ebtables autoupdate BUILD files 2016-12-12 13:30:07 -08:00
env autoupdate BUILD files 2016-12-12 13:30:07 -08:00
errors autoupdate BUILD files 2016-12-12 13:30:07 -08:00
exec autoupdate BUILD files 2016-12-12 13:30:07 -08:00
flag autoupdate BUILD files 2016-12-12 13:30:07 -08:00
flock autoupdate BUILD files 2016-12-12 13:30:07 -08:00
flowcontrol autoupdate BUILD files 2016-12-12 13:30:07 -08:00
flushwriter autoupdate BUILD files 2016-12-12 13:30:07 -08:00
framer autoupdate BUILD files 2016-12-12 13:30:07 -08:00
goroutinemap autoupdate BUILD files 2016-12-12 13:30:07 -08:00
hash autoupdate BUILD files 2016-12-12 13:30:07 -08:00
homedir autoupdate BUILD files 2016-12-12 13:30:07 -08:00
httpstream autoupdate BUILD files 2016-12-12 13:30:07 -08:00
initsystem autoupdate BUILD files 2016-12-12 13:30:07 -08:00
integer autoupdate BUILD files 2016-12-12 13:30:07 -08:00
interrupt autoupdate BUILD files 2016-12-12 13:30:07 -08:00
intstr autoupdate BUILD files 2016-12-12 13:30:07 -08:00
io autoupdate BUILD files 2016-12-12 13:30:07 -08:00
iptables Port iptables code to pkg/util/version, don't use semvers 2016-12-13 08:53:04 -05:00
json autoupdate BUILD files 2016-12-12 13:30:07 -08:00
jsonpath autoupdate BUILD files 2016-12-12 13:30:07 -08:00
keymutex autoupdate BUILD files 2016-12-12 13:30:07 -08:00
labels autoupdate BUILD files 2016-12-12 13:30:07 -08:00
limitwriter autoupdate BUILD files 2016-12-12 13:30:07 -08:00
logs autoupdate BUILD files 2016-12-12 13:30:07 -08:00
maps autoupdate BUILD files 2016-12-12 13:30:07 -08:00
metrics autoupdate BUILD files 2016-12-12 13:30:07 -08:00
mount autoupdate BUILD files 2016-12-12 13:30:07 -08:00
net autoupdate BUILD files 2016-12-12 13:30:07 -08:00
netsh autoupdate BUILD files 2016-12-12 13:30:07 -08:00
node rename /release_1_5 to /clientset 2016-12-14 12:39:48 -08:00
oom autoupdate BUILD files 2016-12-12 13:30:07 -08:00
parsers autoupdate BUILD files 2016-12-12 13:30:07 -08:00
procfs bazel: fix some unit tests 2016-12-15 18:36:22 -08:00
proxy pkg/apiserver: remove unused code 2016-12-16 17:47:47 +01:00
rand autoupdate BUILD files 2016-12-12 13:30:07 -08:00
resourcecontainer autoupdate BUILD files 2016-12-12 13:30:07 -08:00
rlimit autoupdate BUILD files 2016-12-12 13:30:07 -08:00
runtime autoupdate BUILD files 2016-12-12 13:30:07 -08:00
selinux autoupdate BUILD files 2016-12-12 13:30:07 -08:00
sets autoupdate BUILD files 2016-12-12 13:30:07 -08:00
slice autoupdate BUILD files 2016-12-12 13:30:07 -08:00
strategicpatch autoupdate BUILD files 2016-12-12 13:30:07 -08:00
strings autoupdate BUILD files 2016-12-12 13:30:07 -08:00
sysctl autoupdate BUILD files 2016-12-12 13:30:07 -08:00
system autoupdate BUILD files 2016-12-12 13:30:07 -08:00
taints autoupdate BUILD files 2016-12-12 13:30:07 -08:00
term autoupdate BUILD files 2016-12-12 13:30:07 -08:00
testing autoupdate BUILD files 2016-12-12 13:30:07 -08:00
threading autoupdate BUILD files 2016-12-12 13:30:07 -08:00
uuid autoupdate BUILD files 2016-12-12 13:30:07 -08:00
validation Merge pull request #38171 from xingzhou/kube-typo 2016-12-13 11:28:30 -08:00
version Add a package for handling version numbers (including non-semvers) 2016-12-13 08:53:00 -05:00
wait autoupdate BUILD files 2016-12-12 13:30:07 -08:00
workqueue autoupdate BUILD files 2016-12-12 13:30:07 -08:00
wsstream autoupdate BUILD files 2016-12-12 13:30:07 -08:00
yaml Merge pull request #38525 from juanvallejo/jvallejo/fix-panic-on-invalid-json-syntax 2016-12-19 13:23:03 -08:00
BUILD autoupdate BUILD files 2016-12-12 13:30:07 -08:00
doc.go Use Go canonical import paths 2016-07-16 13:48:21 -04:00
template.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
template_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
trace.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
trie.go Make Kubernetes OpenAPI operation IDs unique 2016-10-12 14:54:12 -07:00
umask.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
umask_windows.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
util.go kubelet: storage: don't hang kubelet on unresponsive nfs 2016-10-18 08:45:40 -05:00
util_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00