After a session with ddd, CFLAGS="-g -O1 -Wall -W -pedantic" and even valgrind, i found a lot of minor stuff, and finally the real problem. :) Summary by file: common/item.c The vital fix. Wrong buffer size was used. common/object.c reading uninitialized value (valgrind) include/define.h typo in function safe_strncpy, trailing comma in enum (pedantic) include/global.h c++ style comments include/player.h trailing comma in enum (pedantic) socket/init.c reading uninitialized value (valgrind) Bernd Edler -------------- next part -------------- Index: common/item.c =================================================================== RCS file: /cvsroot/crossfire/crossfire/common/item.c,v retrieving revision 1.38 diff -c -r1.38 item.c *** common/item.c 13 Sep 2003 05:01:27 -0000 1.38 --- common/item.c 10 Dec 2003 18:06:00 -0000 *************** *** 603,617 **** case ROD: if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { if(!op->title) { ! safe_strcat(buf," of ", &len, HUGE_BUF); if (op->inv) ! safe_strcat(buf,op->inv->name, &len, HUGE_BUF); else LOG(llevError,"Spellbook %s lacks inventory\n", op->name); } if(op->type != SPELLBOOK) { sprintf(buf2, " (lvl %d)", op->level); ! safe_strcat(buf, buf2, &len, HUGE_BUF); } } break; --- 603,617 ---- case ROD: if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { if(!op->title) { ! safe_strcat(buf," of ", &len, MAX_BUF); if (op->inv) ! safe_strcat(buf,op->inv->name, &len, MAX_BUF); else LOG(llevError,"Spellbook %s lacks inventory\n", op->name); } if(op->type != SPELLBOOK) { sprintf(buf2, " (lvl %d)", op->level); ! safe_strcat(buf, buf2, &len, MAX_BUF); } } break; Index: common/object.c =================================================================== RCS file: /cvsroot/crossfire/crossfire/common/object.c,v retrieving revision 1.75 diff -c -r1.75 object.c *** common/object.c 27 Oct 2003 07:24:14 -0000 1.75 --- common/object.c 10 Dec 2003 18:06:04 -0000 *************** *** 510,516 **** if (op->msg!=NULL) FREE_AND_CLEAR_STR(op->msg); if (op->lore!=NULL) FREE_AND_CLEAR_STR(op->lore); if (op->materialname!= NULL) FREE_AND_CLEAR_STR(op->materialname); ! /* Using this memset is a lot easier (and probably faster) * than explicitly clearing the fields. --- 510,517 ---- if (op->msg!=NULL) FREE_AND_CLEAR_STR(op->msg); if (op->lore!=NULL) FREE_AND_CLEAR_STR(op->lore); if (op->materialname!= NULL) FREE_AND_CLEAR_STR(op->materialname); ! op->active_next = NULL; ! op->active_prev = NULL; /* Using this memset is a lot easier (and probably faster) * than explicitly clearing the fields. Index: include/define.h =================================================================== RCS file: /cvsroot/crossfire/crossfire/include/define.h,v retrieving revision 1.69 diff -c -r1.69 define.h *** include/define.h 27 Oct 2003 03:44:33 -0000 1.69 --- include/define.h 10 Dec 2003 18:06:07 -0000 *************** *** 721,727 **** strncpy(dest+*curlen, orig, maxlen-*curlen-1); dest[maxlen-1]=0; *curlen += strlen(orig); ! if (*curlen>(maxlen-1)) *curlen=maxlen=1; } --- 721,727 ---- strncpy(dest+*curlen, orig, maxlen-*curlen-1); dest[maxlen-1]=0; *curlen += strlen(orig); ! if (*curlen>(maxlen-1)) *curlen=maxlen-1; } *************** *** 807,813 **** /* Optional flags, for bitwise or with a basic flag */ AP_NO_MERGE = 16, AP_IGNORE_CURSE = 32, ! AP_PRINT = 64, /* Print what to do, don't actually do it */ /* Note this is supported in all the functions */ }; --- 807,813 ---- /* Optional flags, for bitwise or with a basic flag */ AP_NO_MERGE = 16, AP_IGNORE_CURSE = 32, ! AP_PRINT = 64 /* Print what to do, don't actually do it */ /* Note this is supported in all the functions */ }; Index: include/global.h =================================================================== RCS file: /cvsroot/crossfire/crossfire/include/global.h,v retrieving revision 1.44 diff -c -r1.44 global.h *** include/global.h 13 Sep 2003 05:01:33 -0000 1.44 --- include/global.h 10 Dec 2003 18:06:07 -0000 *************** *** 60,73 **** typedef unsigned short Fontindex; #ifdef WIN32 ! // Python plugin stuff defines SIZEOF_LONG_LONG as 8, and besides __int64 is a 64b type on MSVC... ! // So let's force the typedef typedef unsigned __int64 uint64; typedef signed __int64 sint64; ! // Needed for experience #define atoll _atoi64 ! #else // WIN32 #if SIZEOF_LONG == 8 typedef unsigned long uint64; --- 60,75 ---- typedef unsigned short Fontindex; #ifdef WIN32 ! /* Python plugin stuff defines SIZEOF_LONG_LONG as 8, and besides __int64 is a 64b type on MSVC... ! * So let's force the typedef ! */ typedef unsigned __int64 uint64; typedef signed __int64 sint64; ! /* Needed for experience */ #define atoll _atoi64 ! #else ! /* WIN32 */ #if SIZEOF_LONG == 8 typedef unsigned long uint64; Index: include/player.h =================================================================== RCS file: /cvsroot/crossfire/crossfire/include/player.h,v retrieving revision 1.33 diff -c -r1.33 player.h *** include/player.h 13 Sep 2003 05:01:34 -0000 1.33 --- include/player.h 10 Dec 2003 18:06:08 -0000 *************** *** 72,78 **** typedef enum usekeytype { key_inventory=0, keyrings=1, ! containers=2, } usekeytype; /* This is used to control what to do when we need to unapply --- 72,78 ---- typedef enum usekeytype { key_inventory=0, keyrings=1, ! containers=2 } usekeytype; /* This is used to control what to do when we need to unapply *************** *** 81,87 **** typedef enum unapplymode { unapply_nochoice=0, /* Will unapply objects when there no choice to unapply */ unapply_never=1, /* will not unapply objects automatically */ ! unapply_always=2, /* Will unapply whatever is necessary - this goes beyond */ /* no choice - if there are multiple ojbect of the same type */ /* that need to be unapplied, there is no way for the player */ /* to control which of these will be unapplied. */ --- 81,87 ---- typedef enum unapplymode { unapply_nochoice=0, /* Will unapply objects when there no choice to unapply */ unapply_never=1, /* will not unapply objects automatically */ ! unapply_always=2 /* Will unapply whatever is necessary - this goes beyond */ /* no choice - if there are multiple ojbect of the same type */ /* that need to be unapplied, there is no way for the player */ /* to control which of these will be unapplied. */ Index: socket/init.c =================================================================== RCS file: /cvsroot/crossfire/crossfire/socket/init.c,v retrieving revision 1.30 diff -c -r1.30 init.c *** socket/init.c 13 Sep 2003 05:02:14 -0000 1.30 --- socket/init.c 10 Dec 2003 18:06:17 -0000 *************** *** 67,72 **** --- 67,73 ---- int bufsize=65535; /*Supposed absolute upper limit */ int oldbufsize; int buflen=sizeof(int); + int i; #ifdef WIN32 /* ***WIN32 SOCKET: init win32 non blocking socket */ int temp = 1; *************** *** 113,118 **** --- 114,121 ---- ns->itemcmd = 1; /* Default is version item1 command*/ ns->ext_mapinfos=0; /*extendedmapinfo datas*/ ns->EMI_smooth=0; + ns->look_position=0; + ns->update_look=0; /* we should really do some checking here - if total clients overflows * we need to do something more intelligent, because client id's will start *************** *** 125,131 **** * HandleClient for oldsocketmode without checking the * length of data. */ ! ns->inbuf.buf[0] = 0; memset(&ns->lastmap,0,sizeof(struct Map)); memset(&ns->faces_sent,0,sizeof(ns->faces_sent)); memset(&ns->anims_sent,0,sizeof(ns->anims_sent)); --- 128,135 ---- * HandleClient for oldsocketmode without checking the * length of data. */ ! for (i = 0; i<MAXSOCKBUF; i++ ) ! ns->inbuf.buf[i] = 0; memset(&ns->lastmap,0,sizeof(struct Map)); memset(&ns->faces_sent,0,sizeof(ns->faces_sent)); memset(&ns->anims_sent,0,sizeof(ns->anims_sent)); -------------- next part -------------- _______________________________________________ crossfire-devel mailing list crossfire-devel at lists.real-time.com https://mailman.real-time.com/mailman/listinfo/crossfire-devel