Difference for socket/request.c from version 1.92 to 1.93


version 1.92 version 1.93
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_init_c =   * static char *rcsid_init_c =
  *    "$Id: request.c,v 1.92 2006/05/21 10:07:13 akirschbaum Exp $";   *    "$Id: request.c,v 1.93 2006/05/21 10:35:11 akirschbaum Exp $";
  */   */
   
 /*  /*
Line 791
 
Line 791
     char buf[MAX_BUF];      char buf[MAX_BUF];
     uint16 flags;      uint16 flags;
   
     sl.buf=malloc(MAXSOCKBUF);      sl.buf=malloc(MAXSOCKSENDBUF);
     strcpy((char*)sl.buf,"stats ");      strcpy((char*)sl.buf,"stats ");
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
          
Line 886
 
Line 886
   
     pl->last_weight = weight;      pl->last_weight = weight;
   
     sl.buf=malloc(MAXSOCKBUF);      sl.buf=malloc(MAXSOCKSENDBUF);
   
     strcpy((char*)sl.buf,"player ");      strcpy((char*)sl.buf,"player ");
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
Line 925
 
Line 925
  return;   return;
     }      }
   
     sl.buf = malloc(MAXSOCKBUF);      sl.buf = malloc(MAXSOCKSENDBUF);
     strcpy((char*)sl.buf, "anim ");      strcpy((char*)sl.buf, "anim ");
     sl.len=5;      sl.len=5;
     SockList_AddShort(&sl, anim_num);      SockList_AddShort(&sl, anim_num);
Line 1333
 
Line 1333
     mapstruct *m;      mapstruct *m;
     object *m_ob, *t_ob, *ob;      object *m_ob, *t_ob, *ob;
   
     sl.buf=malloc(MAXSOCKBUF);      sl.buf=malloc(MAXSOCKSENDBUF);
     if (pl->contr->socket.mapmode == Map1Cmd)      if (pl->contr->socket.mapmode == Map1Cmd)
  strcpy((char*)sl.buf,"map1 ");   strcpy((char*)sl.buf,"map1 ");
     else      else
Line 1342
 
Line 1342
     startlen = sl.len;      startlen = sl.len;
     /*Extendedmapinfo structure initialisation*/      /*Extendedmapinfo structure initialisation*/
     if (pl->contr->socket.ext_mapinfos){      if (pl->contr->socket.ext_mapinfos){
         esl.buf=malloc(MAXSOCKBUF);          esl.buf=malloc(MAXSOCKSENDBUF);
         strcpy((char*)esl.buf,"mapextended ");          strcpy((char*)esl.buf,"mapextended ");
         esl.len=strlen((char*)esl.buf);          esl.len=strlen((char*)esl.buf);
         extendedinfos=EMI_NOREDRAW;          extendedinfos=EMI_NOREDRAW;
Line 1928
 
Line 1928
     mapstruct *m;      mapstruct *m;
     object *ob;      object *ob;
   
     sl.buf=malloc(MAXSOCKBUF);      sl.buf=malloc(MAXSOCKSENDBUF);
     strcpy((char*)sl.buf,"map2 ");      strcpy((char*)sl.buf,"map2 ");
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
     startlen = sl.len;      startlen = sl.len;
Line 2157
 
Line 2157
 {  {
     struct Map newmap;      struct Map newmap;
     int x,y, mx, my;      int x,y, mx, my;
     char buf[MAXSOCKBUF];      char buf[MAXSOCKSENDBUF];
   
     if (ns->mapmode == Map2Cmd) {      if (ns->mapmode == Map2Cmd) {
  ns->map_scroll_x += dx;   ns->map_scroll_x += dx;
Line 2232
 
Line 2232
     SockList sl;      SockList sl;
     int i;      int i;
   
     sl.buf = malloc(MAXSOCKBUF);      sl.buf = malloc(MAXSOCKSENDBUF);
     strcpy((char*)sl.buf,"replyinfo skill_info\n");      strcpy((char*)sl.buf,"replyinfo skill_info\n");
       sl.len = strlen((char*)sl.buf);
     for (i=1; i< NUM_SKILLS; i++) {      for (i=1; i< NUM_SKILLS; i++) {
  sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", i + CS_STAT_SKILLINFO,   int len;
  skill_names[i]);  
    len = 16+strlen(skill_names[i]); /* upper bound for length */
    if (sl.len+len > MAXSOCKSENDBUF) {
        LOG(llevError, "Buffer overflow in send_skill_info, not sending all skill information\n");
        break;
     }      }
     sl.len = strlen((char*)sl.buf);  
     if (sl.len > MAXSOCKBUF) {   sprintf((char*)sl.buf+sl.len, "%d:%s\n", i+CS_STAT_SKILLINFO, skill_names[i]);
  LOG(llevError,"Buffer overflow in send_skill_info!\n");   sl.len += strlen((char*)sl.buf+sl.len);
  fatal(0);  
     }      }
     Send_With_Handling(ns, &sl);      Send_With_Handling(ns, &sl);
     free(sl.buf);      free(sl.buf);
Line 2255
 
Line 2259
     SockList sl;      SockList sl;
     int i;      int i;
   
     sl.buf = malloc(MAXSOCKBUF);      sl.buf = malloc(MAXSOCKSENDBUF);
     strcpy((char*)sl.buf,"replyinfo spell_paths\n");      strcpy((char*)sl.buf,"replyinfo spell_paths\n");
     for(i=0; i<NRSPELLPATHS; i++)  
  sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", 1<<i, spellpathnames[i]);  
     sl.len = strlen((char*)sl.buf);      sl.len = strlen((char*)sl.buf);
     if (sl.len > MAXSOCKBUF) {      for(i=0; i<NRSPELLPATHS; i++) {
  LOG(llevError,"Buffer overflow in send_spell_paths!\n");   int len;
  fatal(0);  
    len = 16+strlen(spellpathnames[i]); /* upper bound for length */
    if (sl.len+len > MAXSOCKSENDBUF) {
        LOG(llevError, "Buffer overflow in send_spell_paths, not sending all spell information\n");
        break;
    }
   
    sprintf((char*)sl.buf+sl.len, "%d:%s\n", 1<<i, spellpathnames[i]);
    sl.len += strlen((char*)sl.buf+sl.len);
     }      }
     Send_With_Handling(ns, &sl);      Send_With_Handling(ns, &sl);
     free(sl.buf);      free(sl.buf);
Line 2293
 
Line 2303
  flags |= UPD_SP_DAMAGE;   flags |= UPD_SP_DAMAGE;
      }       }
      if (flags !=0) {       if (flags !=0) {
  sl.buf = malloc(MAXSOCKBUF);   sl.buf = malloc(MAXSOCKSENDBUF);
  strcpy((char*)sl.buf,"updspell ");   strcpy((char*)sl.buf,"updspell ");
  sl.len=strlen((char*)sl.buf);   sl.len=strlen((char*)sl.buf);
  SockList_AddChar(&sl, flags);   SockList_AddChar(&sl, flags);
Line 2317
 
Line 2327
  LOG(llevError, "Invalid call to esrv_remove_spell");   LOG(llevError, "Invalid call to esrv_remove_spell");
  return;   return;
     }      }
     sl.buf = malloc(MAXSOCKBUF);      sl.buf = malloc(MAXSOCKSENDBUF);
     strcpy((char*)sl.buf,"delspell ");      strcpy((char*)sl.buf,"delspell ");
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
     SockList_AddInt(&sl, spell->count);      SockList_AddInt(&sl, spell->count);
Line 2385
 
Line 2395
  return;   return;
     }      }
     if (!pl->socket.monitor_spells) return;      if (!pl->socket.monitor_spells) return;
     sl.buf = malloc(MAXSOCKBUF);      sl.buf = malloc(MAXSOCKSENDBUF);
     strcpy((char*)sl.buf,"addspell ");      strcpy((char*)sl.buf,"addspell ");
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
     if (!spell) {      if (!spell) {
  for (spell=pl->ob->inv; spell!=NULL; spell=spell->below) {   for (spell=pl->ob->inv; spell!=NULL; spell=spell->below) {
      if (spell->type != SPELL) continue;       if (spell->type != SPELL) continue;
      /* were we to simply keep appending data here, we could exceed        /* were we to simply keep appending data here, we could exceed
       * MAXSOCKBUF if the player has enough spells to add, we know that        * MAXSOCKSENDBUF if the player has enough spells to add, we know that
       * append_spell will always append 23 data bytes, plus 3 length        * append_spell will always append 23 data bytes, plus 3 length
       * bytes and 2 strings (because that is the spec) so we need to        * bytes and 2 strings (because that is the spec) so we need to
       * check that the length of those 2 strings, plus the 26 bytes,         * check that the length of those 2 strings, plus the 26 bytes,
       * won't take us over the length limit for the socket, if it does,        * won't take us over the length limit for the socket, if it does,
       * we need to send what we already have, and restart packet formation         * we need to send what we already have, and restart packet formation
       */        */
      if (sl.len > (MAXSOCKBUF - (26 + strlen(spell->name) +        if (sl.len > (MAXSOCKSENDBUF - (26 + strlen(spell->name) +
  (spell->msg?strlen(spell->msg):0)))) {   (spell->msg?strlen(spell->msg):0)))) {
  Send_With_Handling(&pl->socket, &sl);   Send_With_Handling(&pl->socket, &sl);
  strcpy((char*)sl.buf,"addspell ");   strcpy((char*)sl.buf,"addspell ");
Line 2413
 
Line 2423
  return;   return;
     }      }
     else append_spell(pl, &sl, spell);      else append_spell(pl, &sl, spell);
     if (sl.len > MAXSOCKBUF) {      if (sl.len > MAXSOCKSENDBUF) {
  LOG(llevError,"Buffer overflow in esrv_add_spells!\n");   LOG(llevError,"Buffer overflow in esrv_add_spells!\n");
  fatal(0);   fatal(0);
     }      }
Line 2436
 
Line 2446
     SockList sl;      SockList sl;
     int tmp;      int tmp;
   
       sl.buf=malloc(MAXSOCKSENDBUF);
     sl.buf=malloc(MAXSOCKBUF);  
     strcpy((char*)sl.buf,"tick ");      strcpy((char*)sl.buf,"tick ");
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
     SockList_AddInt(&sl, pticks);      SockList_AddInt(&sl, pticks);


Legend:
line(s) removed in v.1.92 
line(s) changed
 line(s) added in v.1.93

File made using version 1.98 of cvs2html by leaf at 2011-07-21 19:36