Changeset ddacb9c


Ignore:
Timestamp:
Jun 16, 2008, 1:52:24 PM (16 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
e2257be
Parents:
f151757
Message:
Fix a segfault on retrieving zephyr subs when the user doesn't have any or has expired tickets.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rdd28b51 rddacb9c  
    22
    331.0.2
     4 * Fix a segfault on retrieving zephyr subs when the user doesn't
     5   have any or has expired tickets. -asedeno
    46 * Don't complain about non-existant ~/.owl/startup when starting. -asedeno
    57       
  • zephyr.c

    r02f55dc rddacb9c  
    10081008#ifdef HAVE_LIBZEPHYR
    10091009  int ret, num, i, one;
     1010  int buffsize;
    10101011  ZSubscription_t sub;
    1011   char *out, *tmpbuff;
     1012  char *out;
    10121013  one=1;
    10131014
     
    10151016  if (ret==ZERR_TOOMANYSUBS) {
    10161017    return(owl_strdup("Zephyr: too many subscriptions\n"));
    1017   } else if (ret) {
     1018  } else if (ret || (num <= 0)) {
    10181019    return(owl_strdup("Zephyr: error retriving subscriptions\n"));
    10191020  }
    10201021
    1021   out=owl_malloc(num*500);
    1022   tmpbuff=owl_malloc(num*500);
     1022  buffsize = (num + 1) * 50;
     1023  out=owl_malloc(buffsize);
    10231024  strcpy(out, "");
    10241025  for (i=0; i<num; i++) {
    10251026    if ((ret = ZGetSubscriptions(&sub, &one)) != ZERR_NONE) {
    10261027      owl_free(out);
    1027       owl_free(tmpbuff);
    10281028      ZFlushSubscriptions();
    10291029      out=owl_strdup("Error while getting subscriptions\n");
    10301030      return(out);
    10311031    } else {
    1032       sprintf(tmpbuff, "<%s,%s,%s>\n%s", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient, out);
     1032      int tmpbufflen;
     1033      char *tmpbuff;
     1034      tmpbuff = owl_sprintf("<%s,%s,%s>\n%s", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient, out);
     1035      tmpbufflen = strlen(tmpbuff) + 1;
     1036      if (tmpbufflen > buffsize) {
     1037        char *out2;
     1038        buffsize = tmpbufflen * 2;
     1039        out2 = owl_realloc(out, buffsize);
     1040        if (out2 == NULL) {
     1041          owl_free(out);
     1042          owl_free(tmpbuff);
     1043          ZFlushSubscriptions();
     1044          out=owl_strdup("Realloc error while getting subscriptions\n");
     1045          return(out);   
     1046        }
     1047        out = out2;
     1048      }
    10331049      strcpy(out, tmpbuff);
    1034     }
    1035   }
    1036 
    1037   owl_free(tmpbuff);
     1050      owl_free(tmpbuff);
     1051    }
     1052  }
     1053
    10381054  ZFlushSubscriptions();
    10391055  return(out);
Note: See TracChangeset for help on using the changeset viewer.