)]}'
{
  "commit": "6265eb26a375179f193f792e4f0d49036d2cf052",
  "tree": "42daed0971626ac0a038fa9d695c9002a52dfae0",
  "parents": [
    "47116d1c90cdac94cb9da270320dcf0d5ce1cfe2"
  ],
  "author": {
    "name": "Jim Meyering",
    "email": "jim@meyering.net",
    "time": "Mon Feb 08 19:28:38 2010 +0100"
  },
  "committer": {
    "name": "Anthony Liguori",
    "email": "aliguori@us.ibm.com",
    "time": "Wed Feb 10 14:00:53 2010 -0600"
  },
  "message": "don\u0027t dereference NULL after failed strdup\n\nMost of these are obvious NULL-deref bug fixes, for example,\nthe ones in these files:\n\n  block/curl.c\n  net.c\n  slirp/misc.c\n\nand the first one in block/vvfat.c.\nThe others in block/vvfat.c may not lead to an immediate segfault, but I\ntraced the two schedule_rename(..., strdup(path)) uses, and a failed\nstrdup would appear to trigger this assertion in handle_renames_and_mkdirs:\n\n\t    assert(commit-\u003epath);\n\nThe conversion to use qemu_strdup in envlist_to_environ is not technically\nneeded, but does avoid a theoretical leak in the caller when strdup fails\nfor one value, but later succeeds in allocating another buffer(plausible,\nif one string length is much larger than the others).  The caller does\nnot know the length of the returned list, and as such can only free\npointers until it hits the first NULL.  If there are non-NULL pointers\nbeyond the first, their buffers would be leaked.  This one is admittedly\nfar-fetched.\n\nThe two in linux-user/main.c are worth fixing to ensure that an\nOOM error is diagnosed up front, rather than letting it provoke some\nharder-to-diagnose secondary error, in case of exec failure, or worse, in\ncase the exec succeeds but with an invalid list of command line options.\nHowever, considering how unlikely it is to encounter a failed strdup early\nin main, this isn\u0027t a big deal.  Note that adding the required uses of\nqemu_strdup here and in envlist.c induce link failures because qemu_strdup\nis not currently in any library they\u0027re linked with.  So for now, I\u0027ve\nomitted those changes, as well as the fixes in target-i386/helper.c\nand target-sparc/helper.c.\n\nIf you\u0027d like to see the above discussion (or anything else)\nin the commit log, just let me know and I\u0027ll be happy to adjust.\n\n\u003eFrom 9af42864fd1ea666bd25e2cecfdfae74c20aa8c7 Mon Sep 17 00:00:00 2001\nFrom: Jim Meyering \u003cmeyering@redhat.com\u003e\nDate: Mon, 8 Feb 2010 18:29:29 +0100\nSubject: [PATCH] don\u0027t dereference NULL after failed strdup\n\nHandle failing strdup by replacing each use with qemu_strdup,\nso as not to dereference NULL or trigger a failing assertion.\n* block/curl.c (curl_open): s/\\bstrdup\\b/qemu_strdup/\n* block/vvfat.c (init_directories): Likewise.\n(get_cluster_count_for_direntry, check_directory_consistency): Likewise.\n* net.c (parse_host_src_port): Likewise.\n* slirp/misc.c (fork_exec): Likewise.\n\nSigned-off-by: Anthony Liguori \u003caliguori@us.ibm.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "fe08f7b800835be047dd3bdb1aa898eb0865d95d",
      "old_mode": 33188,
      "old_path": "block/curl.c",
      "new_id": "2cf72cb4e827039d1d48c7f4fd351283d70cf658",
      "new_mode": 33188,
      "new_path": "block/curl.c"
    },
    {
      "type": "modify",
      "old_id": "d2787b9e761e6720ae1925aa5a3d4ef585365916",
      "old_mode": 33188,
      "old_path": "block/vvfat.c",
      "new_id": "bb707c000820319d5e1d131623223e4242b30121",
      "new_mode": 33188,
      "new_path": "block/vvfat.c"
    },
    {
      "type": "modify",
      "old_id": "6ef93e615c8db9d2de230fc1b988213d763ba4f7",
      "old_mode": 33188,
      "old_path": "net.c",
      "new_id": "8e951ca9daee05d91026812ed54fd0d1d62fcad3",
      "new_mode": 33188,
      "new_path": "net.c"
    },
    {
      "type": "modify",
      "old_id": "05f4fb329f3e889727f338a82caceabcc973f7c9",
      "old_mode": 33188,
      "old_path": "slirp/misc.c",
      "new_id": "dcb1dc117beb6833c126de0932f0c9e10f12a1c0",
      "new_mode": 33188,
      "new_path": "slirp/misc.c"
    }
  ]
}
