fixed wrong definition of mio_skad_alt_t

made skad clearing safer
This commit is contained in:
hyung-hwan 2020-11-15 13:15:33 +00:00
parent 43330b44b6
commit 5e80418e5a
2 changed files with 10 additions and 3 deletions

View File

@ -43,6 +43,10 @@
# undef MIO_SIZEOF_SKAD_T # undef MIO_SIZEOF_SKAD_T
# define MIO_SIZEOF_SKAD_T MIO_SIZEOF_STRUCT_SOCKADDR_LL # define MIO_SIZEOF_SKAD_T MIO_SIZEOF_STRUCT_SOCKADDR_LL
#endif #endif
#if (MIO_SIZEOF_STRUCT_SOCKADDR_DL > MIO_SIZEOF_SKAD_T)
# undef MIO_SIZEOF_SKAD_T
# define MIO_SIZEOF_SKAD_T MIO_SIZEOF_STRUCT_SOCKADDR_DL
#endif
#if (MIO_SIZEOF_STRUCT_SOCKADDR_UN > MIO_SIZEOF_SKAD_T) #if (MIO_SIZEOF_STRUCT_SOCKADDR_UN > MIO_SIZEOF_SKAD_T)
# undef MIO_SIZEOF_SKAD_T # undef MIO_SIZEOF_SKAD_T
# define MIO_SIZEOF_SKAD_T MIO_SIZEOF_STRUCT_SOCKADDR_UN # define MIO_SIZEOF_SKAD_T MIO_SIZEOF_STRUCT_SOCKADDR_UN

View File

@ -379,7 +379,8 @@ int mio_ucharstoskad (mio_t* mio, const mio_uch_t* str, mio_oow_t len, mio_skad_
return -1; return -1;
} }
MIO_MEMSET (skad, 0, MIO_SIZEOF(*skad)); /* use MIO_SIZEOF(*_skad) instead of MIO_SIZEOF(*skad) in case they are different */
MIO_MEMSET (skad, 0, MIO_SIZEOF(*_skad));
#if defined(AF_UNIX) #if defined(AF_UNIX)
if (*p == '/' && len >= 2) if (*p == '/' && len >= 2)
@ -592,7 +593,8 @@ int mio_bcharstoskad (mio_t* mio, const mio_bch_t* str, mio_oow_t len, mio_skad_
return -1; return -1;
} }
MIO_MEMSET (skad, 0, MIO_SIZEOF(*skad)); /* use MIO_SIZEOF(*_skad) instead of MIO_SIZEOF(*skad) in case they are different */
MIO_MEMSET (skad, 0, MIO_SIZEOF(*_skad));
#if defined(AF_UNIX) #if defined(AF_UNIX)
if (*p == '/' && len >= 2) if (*p == '/' && len >= 2)
@ -1457,7 +1459,8 @@ void mio_clear_skad (mio_skad_t* _skad)
{ {
mio_skad_alt_t* skad = (mio_skad_alt_t*)_skad; mio_skad_alt_t* skad = (mio_skad_alt_t*)_skad;
/*MIO_STATIC_ASSERT (MIO_SIZEOF(*_skad) >= MIO_SIZEOF(*skad));*/ /*MIO_STATIC_ASSERT (MIO_SIZEOF(*_skad) >= MIO_SIZEOF(*skad));*/
MIO_MEMSET (skad, 0, MIO_SIZEOF(*skad)); /* use MIO_SIZEOF(*_skad) instead of MIO_SIZEOF(*skad) in case they are different */
MIO_MEMSET (skad, 0, MIO_SIZEOF(*_skad));
skad->sa.sa_family = MIO_AF_UNSPEC; skad->sa.sa_family = MIO_AF_UNSPEC;
} }