{"action":"created","issue":{"url":"https://api.github.com/repos/pkg/xattr/issues/30","repository_url":"https://api.github.com/repos/pkg/xattr","labels_url":"https://api.github.com/repos/pkg/xattr/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/pkg/xattr/issues/30/comments","events_url":"https://api.github.com/repos/pkg/xattr/issues/30/events","html_url":"https://github.com/pkg/xattr/pull/30","id":343780646,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMzMxODc4","number":30,"title":"get: handle changes between size check and actual get","user":{"login":"rfjakob","id":286847,"node_id":"MDQ6VXNlcjI4Njg0Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/286847?v=4","gravatar_id":"","url":"https://api.github.com/users/rfjakob","html_url":"https://github.com/rfjakob","followers_url":"https://api.github.com/users/rfjakob/followers","following_url":"https://api.github.com/users/rfjakob/following{/other_user}","gists_url":"https://api.github.com/users/rfjakob/gists{/gist_id}","starred_url":"https://api.github.com/users/rfjakob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfjakob/subscriptions","organizations_url":"https://api.github.com/users/rfjakob/orgs","repos_url":"https://api.github.com/users/rfjakob/repos","events_url":"https://api.github.com/users/rfjakob/events{/privacy}","received_events_url":"https://api.github.com/users/rfjakob/received_events","type":"User","site_admin":false},"labels":[{"id":471474759,"node_id":"MDU6TGFiZWw0NzE0NzQ3NTk=","url":"https://api.github.com/repos/pkg/xattr/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"open","locked":false,"assignee":{"login":"kuba--","id":4056521,"node_id":"MDQ6VXNlcjQwNTY1MjE=","avatar_url":"https://avatars1.githubusercontent.com/u/4056521?v=4","gravatar_id":"","url":"https://api.github.com/users/kuba--","html_url":"https://github.com/kuba--","followers_url":"https://api.github.com/users/kuba--/followers","following_url":"https://api.github.com/users/kuba--/following{/other_user}","gists_url":"https://api.github.com/users/kuba--/gists{/gist_id}","starred_url":"https://api.github.com/users/kuba--/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuba--/subscriptions","organizations_url":"https://api.github.com/users/kuba--/orgs","repos_url":"https://api.github.com/users/kuba--/repos","events_url":"https://api.github.com/users/kuba--/events{/privacy}","received_events_url":"https://api.github.com/users/kuba--/received_events","type":"User","site_admin":false},"assignees":[{"login":"kuba--","id":4056521,"node_id":"MDQ6VXNlcjQwNTY1MjE=","avatar_url":"https://avatars1.githubusercontent.com/u/4056521?v=4","gravatar_id":"","url":"https://api.github.com/users/kuba--","html_url":"https://github.com/kuba--","followers_url":"https://api.github.com/users/kuba--/followers","following_url":"https://api.github.com/users/kuba--/following{/other_user}","gists_url":"https://api.github.com/users/kuba--/gists{/gist_id}","starred_url":"https://api.github.com/users/kuba--/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuba--/subscriptions","organizations_url":"https://api.github.com/users/kuba--/orgs","repos_url":"https://api.github.com/users/kuba--/repos","events_url":"https://api.github.com/users/kuba--/events{/privacy}","received_events_url":"https://api.github.com/users/kuba--/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2018-07-23T20:19:43Z","updated_at":"2018-07-26T22:17:38Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/pkg/xattr/pulls/30","html_url":"https://github.com/pkg/xattr/pull/30","diff_url":"https://github.com/pkg/xattr/pull/30.diff","patch_url":"https://github.com/pkg/xattr/pull/30.patch"},"body":"Testing gocryptfs with xfstests generic/037, an unhandled\r\ncorner case was discovered that results in this error:\r\n\r\n  test_xattr_replace: user.something: Numerical result out of range\r\n\r\nThe problem is that the xattr value can change between the size check\r\nand the actual get, and if has gotten bigger, the get will fail with\r\nERANGE. Handle this case by retrying.\r\n\r\nNote: please look at the diff with \"git diff -w\":\r\n```diff\r\ndiff --git a/xattr.go b/xattr.go\r\nindex 4b5ba02..4a11a17 100644\r\n--- a/xattr.go\r\n+++ b/xattr.go\r\n@@ -15,6 +15,10 @@ Get will follow \"symlink1\" and \"symlink2\" and operate on the target of\r\n */\r\n package xattr\r\n \r\n+import (\r\n+       \"syscall\"\r\n+)\r\n+\r\n // Error records an error and the operation, file path and attribute that caused it.\r\n type Error struct {\r\n        Op   string\r\n@@ -43,6 +47,7 @@ type getxattrFunc func(path string, name string, data []byte) (int, error)\r\n // get contains the buffer allocation logic used by both Get and LGet.\r\n func get(path string, name string, getxattrFunc getxattrFunc) ([]byte, error) {\r\n        myname := \"xattr.get\"\r\n+       for {\r\n                // find size.\r\n                size, err := getxattrFunc(path, name, nil)\r\n                if err != nil {\r\n@@ -52,6 +57,11 @@ func get(path string, name string, getxattrFunc getxattrFunc) ([]byte, error) {\r\n                        data := make([]byte, size)\r\n                        // Read into buffer of that size.\r\n                        read, err := getxattrFunc(path, name, data)\r\n+                       if err == syscall.ERANGE {\r\n+                               // The buffer was too small (the xattr must have changed after\r\n+                               // the check). Try again.\r\n+                               continue\r\n+                       }\r\n                        if err != nil {\r\n                                return nil, &Error{myname, path, name, err}\r\n                        }\r\n@@ -59,6 +69,7 @@ func get(path string, name string, getxattrFunc getxattrFunc) ([]byte, error) {\r\n                }\r\n                return []byte{}, nil\r\n        }\r\n+}\r\n \r\n // Set associates name and data together as an attribute of path.\r\n func Set(path, name string, data []byte) error {\r\n```"},"comment":{"url":"https://api.github.com/repos/pkg/xattr/issues/comments/408252240","html_url":"https://github.com/pkg/xattr/pull/30#issuecomment-408252240","issue_url":"https://api.github.com/repos/pkg/xattr/issues/30","id":408252240,"node_id":"MDEyOklzc3VlQ29tbWVudDQwODI1MjI0MA==","user":{"login":"kuba--","id":4056521,"node_id":"MDQ6VXNlcjQwNTY1MjE=","avatar_url":"https://avatars1.githubusercontent.com/u/4056521?v=4","gravatar_id":"","url":"https://api.github.com/users/kuba--","html_url":"https://github.com/kuba--","followers_url":"https://api.github.com/users/kuba--/followers","following_url":"https://api.github.com/users/kuba--/following{/other_user}","gists_url":"https://api.github.com/users/kuba--/gists{/gist_id}","starred_url":"https://api.github.com/users/kuba--/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuba--/subscriptions","organizations_url":"https://api.github.com/users/kuba--/orgs","repos_url":"https://api.github.com/users/kuba--/repos","events_url":"https://api.github.com/users/kuba--/events{/privacy}","received_events_url":"https://api.github.com/users/kuba--/received_events","type":"User","site_admin":false},"created_at":"2018-07-26T22:17:38Z","updated_at":"2018-07-26T22:17:38Z","author_association":"MEMBER","body":"@rfjakob - because I wrote similar tests. For instance on OSX your test passes without any fix and returns just `999`"}}
{"actor":{"display_login":"kuba--"}}