kubernetes/pkg
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
..
admission Merge pull request #38315 from mikedanese/pin-gazel 2016-12-12 19:32:29 -08:00
api Remove extensions/v1beta1 Job 2016-12-17 00:07:24 +01:00
apimachinery Remove GroupMeta.Codec 2016-12-15 14:20:26 -08:00
apis Remove extensions/v1beta1 Job - generated changes 2016-12-17 00:07:25 +01:00
apiserver Merge pull request #38191 from sttts/sttts-move-master-options 2016-12-17 01:25:45 -08:00
auth update for controller RBAC roles 2016-12-15 09:18:48 -05:00
capabilities autoupdate BUILD files 2016-12-12 13:30:07 -08:00
client Remove extensions/v1beta1 Job - generated changes 2016-12-17 00:07:25 +01:00
cloudprovider Merge pull request #38818 from jsafrane/aws-device-allocator 2016-12-15 11:04:17 -08:00
controller Merge pull request #38080 from kargakis/requeue-on-selector-updates 2016-12-19 07:31:15 -08:00
conversion autoupdate BUILD files 2016-12-12 13:30:07 -08:00
credentialprovider autoupdate BUILD files 2016-12-12 13:30:07 -08:00
dns rename /release_1_5 to /clientset 2016-12-14 12:39:48 -08:00
fieldpath autoupdate BUILD files 2016-12-12 13:30:07 -08:00
fields autoupdate BUILD files 2016-12-12 13:30:07 -08:00
generated Remove extensions/v1beta1 Job - generated changes 2016-12-17 00:07:25 +01:00
genericapiserver Merge pull request #38191 from sttts/sttts-move-master-options 2016-12-17 01:25:45 -08:00
healthz Merge pull request #34410 from yuexiao-wang/heathz-log 2016-12-14 15:09:53 -08:00
httplog autoupdate BUILD files 2016-12-12 13:30:07 -08:00
hyperkube autoupdate BUILD files 2016-12-12 13:30:07 -08:00
kubectl Merge pull request #38903 from deads2k/cli-16-fix-generic-create 2016-12-19 07:42:45 -08:00
kubelet Merge pull request #38191 from sttts/sttts-move-master-options 2016-12-17 01:25:45 -08:00
kubemark run hack/update-codegen.sh 2016-12-14 12:39:49 -08:00
labels autoupdate BUILD files 2016-12-12 13:30:07 -08:00
master Merge pull request #38191 from sttts/sttts-move-master-options 2016-12-17 01:25:45 -08:00
metrics rename /release_1_5 to /clientset 2016-12-14 12:39:48 -08:00
probe autoupdate BUILD files 2016-12-12 13:30:07 -08:00
proxy Refactor port allocation logic a little, deflake tests. 2016-12-18 21:18:34 -08:00
quota rename /release_1_5 to /clientset 2016-12-14 12:39:48 -08:00
registry Merge pull request #38191 from sttts/sttts-move-master-options 2016-12-17 01:25:45 -08:00
routes autoupdate BUILD files 2016-12-12 13:30:07 -08:00
runtime Merge pull request #38525 from juanvallejo/jvallejo/fix-panic-on-invalid-json-syntax 2016-12-19 13:23:03 -08:00
security autoupdate BUILD files 2016-12-12 13:30:07 -08:00
securitycontext autoupdate BUILD files 2016-12-12 13:30:07 -08:00
selection autoupdate BUILD files 2016-12-12 13:30:07 -08:00
serviceaccount rename /release_1_5 to /clientset 2016-12-14 12:39:48 -08:00
ssh autoupdate BUILD files 2016-12-12 13:30:07 -08:00
storage Reduce amount of allocations in cacher 2016-12-19 13:51:07 +01:00
types autoupdate BUILD files 2016-12-12 13:30:07 -08:00
util Merge pull request #38525 from juanvallejo/jvallejo/fix-panic-on-invalid-json-syntax 2016-12-19 13:23:03 -08:00
version Rename build-tools/ back to build/ 2016-12-14 13:42:15 -08:00
volume rename /release_1_5 to /clientset 2016-12-14 12:39:48 -08:00
watch autoupdate BUILD files 2016-12-12 13:30:07 -08:00
OWNERS Remove bgrant from pkg/OWNERS and pkg/kubectl/OWNERS since he has plenty to do. 2016-06-16 08:21:27 -07:00