[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interfa
From: |
Balamuruhan S |
Subject: |
Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib |
Date: |
Sun, 11 Aug 2019 12:09:15 +0530 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 |
On 8/8/19 3:39 PM, Stefan Hajnoczi wrote:
> On Wed, Aug 07, 2019 at 12:44:40PM +0530, Balamuruhan S wrote:
>> +void python_args_init_cast_int(char *args[], int arg, int pos)
>> +{
>> + args[pos]= malloc(sizeof(int));
>> + sprintf(args[pos], "%d", arg);
>> +}
> This is broken. args[pos] is a (possibly NULL) pointer to 4 bytes.
> sprintf() will buffer overflow if arg has more than 3 digits.
>
> A correct way to do this is:
>
> args[pos] = g_strdup_printf("%d", arg);
Thanks for correcting it.
>
>> +void python_args_init_cast_long(char *args[], uint64_t arg, int pos)
>> +{
>> + args[pos]= g_malloc(sizeof(uint64_t) * 2);
>> + sprintf(args[pos], "%lx", arg);
>> +}
> Same issue.
>
>> +void python_args_clean(char *args[], int nargs)
>> +{
>> + for (int i = 0; i < nargs; i++) {
>> + g_free(args[i]);
>> + }
>> +}
> Mixing malloc() and g_free() is unsafe. If you switch to
> g_strdup_printf() then g_free() is correct.
sure, I will fix it.
- [Qemu-devel] [RFC PATCH 0/6] Enhancing Qemu MMIO emulation with scripting interface, Balamuruhan S, 2019/08/07
- [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib, Balamuruhan S, 2019/08/07
- Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib, Philippe Mathieu-Daudé, 2019/08/07
- Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib, Stefan Hajnoczi, 2019/08/08
- Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib, Philippe Mathieu-Daudé, 2019/08/08
- Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib, Daniel P . Berrangé, 2019/08/08
- Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib, Stefan Hajnoczi, 2019/08/09
- Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib, Balamuruhan S, 2019/08/12
Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib, Stefan Hajnoczi, 2019/08/08
- Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib,
Balamuruhan S <=
Re: [Qemu-devel] [RFC PATCH 1/6] utils/python_api: add scripting interface for Qemu with python lib, Daniel P . Berrangé, 2019/08/08
[Qemu-devel] [RFC PATCH 2/6] hw/ppc/pnv_xscom: extend xscom to use python interface, Balamuruhan S, 2019/08/07
[Qemu-devel] [RFC PATCH 3/6] hw/ppc/pnv_homer: add homer/occ common area emulation for PowerNV, Balamuruhan S, 2019/08/07