miniupnpc: use C99 flexible array member for struct UPNPDev

see #462
This commit is contained in:
Thomas Bernard 2020-05-29 17:59:38 +02:00
parent 7be0b48022
commit 47a55b27c7
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
2 changed files with 16 additions and 9 deletions

View File

@ -1,12 +1,11 @@
/* $Id: minissdpc.c,v 1.40 2019/04/23 12:12:55 nanard Exp $ */
/* $Id: minissdpc.c,v 1.43 2020/05/29 15:57:42 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* Project : miniupnp
* Web : http://miniupnp.free.fr/
* Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* Author : Thomas BERNARD
* copyright (c) 2005-2019 Thomas Bernard
* copyright (c) 2005-2020 Thomas Bernard
* This software is subjet to the conditions detailed in the
* provided LICENCE file. */
/*#include <syslog.h>*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -886,7 +885,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
* no duplicate device was found */
if(tmp)
continue;
tmp = (struct UPNPDev *)malloc(sizeof(struct UPNPDev)+urlsize+stsize+usnsize);
tmp = (struct UPNPDev *)malloc(sizeof(struct UPNPDev)+urlsize+stsize+usnsize+3);
if(!tmp) {
/* memory allocation error */
if(error)

View File

@ -1,8 +1,8 @@
/* $Id: upnpdev.h,v 1.1 2015/08/28 12:14:19 nanard Exp $ */
/* $Id: upnpdev.h,v 1.3 2020/05/29 15:57:42 nanard Exp $ */
/* Project : miniupnp
* Web : http://miniupnp.free.fr/
* Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* Author : Thomas BERNARD
* copyright (c) 2005-2018 Thomas Bernard
* copyright (c) 2005-2020 Thomas Bernard
* This software is subjet to the conditions detailed in the
* provided LICENSE file. */
#ifndef UPNPDEV_H_INCLUDED
@ -20,7 +20,15 @@ struct UPNPDev {
char * st;
char * usn;
unsigned int scope_id;
char buffer[3];
#if defined(__STDC_VERSION) && __STDC_VERSION__ >= 199901L
/* C99 flexible array member */
char buffer[];
#elif defined(__GNUC__)
char buffer[0];
#else
/* Fallback to a hack */
char buffer[1];
#endif
};
/* freeUPNPDevlist()