)]}'
{
  "commit": "fc240bb143ca808cf67ed94ec8d9c0a4567dc89b",
  "tree": "949019ae54d22b50ff435f367f09e75476def912",
  "parents": [
    "7eceaa69efddc3bfecfeab1179a580309c5a646e"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Tue May 21 11:22:26 2024 +0100"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Tue Jun 11 20:41:16 2024 +0100"
  },
  "message": "gdb/fileio: fix errno for packets where an attachment is expected\n\nIn remote.c lives remote_target::remote_hostio_send_command(), which\nis used to handle sending a fileio packet to the remote, and for\nparsing the reply packet.\n\nSome commands, e.g. open, pwrite, close, send some arguments to the\nremote, and then get back a single integer return value.\n\nOther commands though, e.g. pread, readlink, fstat, send some\narguments and get back an integer return value and some additional\ndata.  This additional data is called the attachment.\n\nExcept, we only get the attachment if the command completes\nsuccessfully.  For example, calling readlink with a non existent path\nwill result in a return packet: \u0027F-1,2\u0027 with no attachment.  This is\nas expected.\n\nWithin remote_hostio_send_command we call remote_hostio_parse_result,\nthis parses the status code (-1 in our example above) and\nthen parses the errno value (2 in our example above).\n\nBack in remote_hostio_parse_result we then hit this block:\n\n  /* Make sure we saw an attachment if and only if we expected one.  */\n  if ((attachment_tmp \u003d\u003d NULL \u0026\u0026 attachment !\u003d NULL)\n      || (attachment_tmp !\u003d NULL \u0026\u0026 attachment \u003d\u003d NULL))\n    {\n      *remote_errno \u003d FILEIO_EINVAL;\n      return -1;\n    }\n\nWhich ensures that commands that expect an attachment, got an\nattachment.\n\nThe problem is, we\u0027ll only get an attachment if the command\nsucceeded.  If it didn\u0027t, then there is no attachment, and that is as\nexpected.\n\nAs remote_hostio_parse_result always sets the returned error number to\nFILEIO_SUCCESS unless the packet contained an actual error\nnumber (e.g. 2 in our example above), I suggest we should return early\nif remote_hostio_parse_result indicates an error packet.\n\nI ran into this issue while working on another patch.  In that patch I\nwas checking the error code returned by a remote readlink call and\nspotted that when I passed an invalid path I got EINVAL instead of\nENOENT.  This patch fixes this issue.\n\nUnfortunately the patch I was working on evolved, and my need to check\nthe error code went away, and so, right now, I have no way to reveal\nthis bug.  But I think this is an obviously correct fix, and worth\nmerging even without a test.\n\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "311430b12a1018eaa14d6afb0142b892f5580196",
      "old_mode": 33188,
      "old_path": "gdb/remote.c",
      "new_id": "2a483f91f76ba7fe08bf0bf37dc7dccb2b89ed85",
      "new_mode": 33188,
      "new_path": "gdb/remote.c"
    }
  ]
}
