Changeset ee6b30f for zephyr.c


Ignore:
Timestamp:
Oct 8, 2017, 6:02:19 PM (7 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master
Children:
4fd3c04
Parents:
09530e6
git-author:
Anders Kaseorg <andersk@mit.edu> (10/07/17 03:25:44)
git-committer:
Anders Kaseorg <andersk@mit.edu> (10/08/17 18:02:19)
Message:
Avoid thread-unsafe functions ctime, localtime, strtok

BarnOwl seems to be growing threads at an alarming rate, so let’s be
sure these don’t turn into race conditions.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    rff58239 ree6b30f  
    284284  FILE *file;
    285285  int fopen_errno;
    286   char *tmp, *start;
     286  char *tmp, *start, *saveptr;
    287287  char *buffer = NULL;
    288288  char *subsfile;
     
    319319   
    320320    /* add it to the list of subs */
    321     if ((tmp = strtok(start, ",\n\r")) == NULL)
     321    if ((tmp = strtok_r(start, ",\n\r", &saveptr)) == NULL)
    322322      continue;
    323323    subs[count].zsub_class = g_strdup(tmp);
    324     if ((tmp=strtok(NULL, ",\n\r")) == NULL)
     324    if ((tmp = strtok_r(NULL, ",\n\r", &saveptr)) == NULL)
    325325      continue;
    326326    subs[count].zsub_classinst = g_strdup(tmp);
    327     if ((tmp = strtok(NULL, " \t\n\r")) == NULL)
     327    if ((tmp = strtok_r(NULL, " \t\n\r", &saveptr)) == NULL)
    328328      continue;
    329329    subs[count].zsub_recipient = g_strdup(tmp);
Note: See TracChangeset for help on using the changeset viewer.