From 6aafae575a25f29d278569716127eb461aff626d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20DEL=20NERO?= Date: Tue, 14 Nov 2023 19:27:08 +0100 Subject: [PATCH] Null pointer Dereference. --- lib_jtag_core/src/os_interface/os_interface.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib_jtag_core/src/os_interface/os_interface.c b/lib_jtag_core/src/os_interface/os_interface.c index 2240d24..2f2f517 100644 --- a/lib_jtag_core/src/os_interface/os_interface.c +++ b/lib_jtag_core/src/os_interface/os_interface.c @@ -317,7 +317,7 @@ int genos_createthread(jtag_core* jtag_ctx,void* hwcontext,THREADFUNCTION thread pthread_attr_setschedparam (&threadattrib, ¶m); print_callback = jtag_ctx->jtagcore_print_callback; - + threadinitptr=(threadinit *)malloc(sizeof(threadinit)); if(threadinitptr) { @@ -333,7 +333,7 @@ int genos_createthread(jtag_core* jtag_ctx,void* hwcontext,THREADFUNCTION thread } else { - print_callback("genos_createthread : memory allocation failed !"); + print_callback("genos_createthread : memory allocation failed !"); } return sit; @@ -453,7 +453,7 @@ char * genos_getfilenameext(char * fullpath,char * filenameext, int type ) char * filename; int len,i; - filename=genos_getfilenamebase(fullpath,0,type); + filename = genos_getfilenamebase(fullpath,0,type); if(filename) { @@ -550,6 +550,7 @@ int genos_checkfileext(char * path,char *ext,int type) { char pathext[16]; char srcext[16]; + char * ptr; if(path && ext) { @@ -557,7 +558,11 @@ int genos_checkfileext(char * path,char *ext,int type) srcext[0] = ' '; srcext[1] = '\0'; - if( ( strlen(genos_getfilenameext(path,0,type)) < 16 ) && ( strlen(ext) < 16 )) + ptr = genos_getfilenameext(path,0,type); + if(!ptr) + return 0; + + if( ( strlen(ptr) < 16 ) && ( strlen(ext) < 16 )) { genos_getfilenameext(path,(char*)&pathext,type); genos_strlower(pathext);