)]}'
{
  "commit": "f8c4789c7f4efa3726ec39256b9860e4df9f8177",
  "tree": "4730d961ad68a11f4c07008d4806638c30c1994d",
  "parents": [
    "ad923ded82d0ede5a2506a9fbd0f5a5a6728e1a6"
  ],
  "author": {
    "name": "Alan Modra",
    "email": "amodra@gmail.com",
    "time": "Wed Aug 02 11:27:27 2023 +0930"
  },
  "committer": {
    "name": "Alan Modra",
    "email": "amodra@gmail.com",
    "time": "Thu Aug 03 21:20:33 2023 +0930"
  },
  "message": "readelf sprintf optimisation\n\nThis replaces sprintf and strcat calls with stpcpy, and makes use of\nsprintf return value rather than using strlen, for get_machine_flags.\n\ndecode_NDS32_machine_flags made use of snprintf, which is arguably the\n\"correct\" way to do things if there can be a buffer overflow.  In this\ncase I don\u0027t think there can be, the buffer is 1k in size which is at\nleast 5 times more than needed.  What\u0027s more, snprintf returns the\ncount of chars that would be output given no buffer limit, which means\ncode like\n  r +\u003d snprintf (buf + r, size - r, ...);\n  r +\u003d snprintf (buf + r, size - r, ...);\nis just wrong.  There needs to be a check on the return value in order\nto prevent buf + r being out of bounds for the second snprintf call.\n\nBTW, if you look closely you\u0027ll see the return value of the decode\nfunctions is unused.  I admit to getting a little carried away with\nwriting \"out \u003d stpcpy (out, ...):\" in each of the decode functions and\ndidn\u0027t notice that until get_machine_flags was trimmed down to a much\nsmaller size.  When I did notice, I decided it\u0027s not such a bad thing.\n\n\t* readelf.c (decode_ARC_machine_flags, decode_ARM_machine_flags),\n\t(decode_AVR_machine_flags, decode_NDS32_machine_flags),\n\t(decode_AMDGPU_machine_flags): Use stpcpy and sprintf return\n\tvalue.  Return end of string.\n\t(decode_BLACKFIN_machine_flags, decode_FRV_machine_flags),\n\t(decode_IA64_machine_flags, decode_LOONGARCH_machine_flags),\n\t(decode_M68K_machine_flags, decode_MeP_machine_flags),\n\t(decode_MIPS_machine_flags, decode_MSP430_machine_flags),\n\t(decode_PARISC_machine_flags, decode_RISCV_machine_flags),\n\t(decode_RL78_machine_flags, decode_RX_machine_flags),\n\t(decode_SH_machine_flags, decode_SPARC_machine_flags),\n\t(decode_V800_machine_flags, decode_V850_machine_flags),\n\t(decode_Z80_machine_flags): New functions, split out from..\n\t(get_machine_flags): ..here.  Similarly use stpcpy.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "4ecff4c393387f961ce5a398897982b6c7e90c27",
      "old_mode": 33188,
      "old_path": "binutils/readelf.c",
      "new_id": "bd112ff53a66969091d8531ced46c56f54145e52",
      "new_mode": 33188,
      "new_path": "binutils/readelf.c"
    }
  ]
}
