Exemple #1
0
/*
 * Clean up a DCS block.  This routine is called to clear out any
 * lingering state information when the CA FSM reverts to an 'earlier'
 * state (Down or Master/Slave Negotiation).
 *
 * Arguments:
 *	dcsp	pointer to a DCS control block for the neighbor
 *
 * Returns:
 *	none
 *
 */
void
scsp_dcs_cleanup(Scsp_dcs *dcsp)
{
	Scsp_cse	*csep, *ncsep;
	Scsp_csa	*csap, *next_csap;
	Scsp_csu_rexmt	*rxp, *rx_next;

	/*
	 * Free any CSAS entries waiting to be sent
	 */
	for (csep = dcsp->sd_ca_csas; csep; csep = ncsep) {
		ncsep = csep->sc_next;
		UNLINK(csep, Scsp_cse, dcsp->sd_ca_csas, sc_next);
		UM_FREE(csep);
	}

	/*
	 * Free any entries on the CRL
	 */
	for (csap = dcsp->sd_crl; csap; csap = next_csap) {
		next_csap = csap->next;
		UNLINK(csap, Scsp_csa, dcsp->sd_crl, next);
		SCSP_FREE_CSA(csap);
	}

	/*
	 * Free any saved CA message and cancel the CA
	 * retransmission timer
	 */
	if (dcsp->sd_ca_rexmt_msg) {
		scsp_free_msg(dcsp->sd_ca_rexmt_msg);
		dcsp->sd_ca_rexmt_msg = NULL;
	}
	HARP_CANCEL(&dcsp->sd_ca_rexmt_t);

	/*
	 * Free any saved CSU Solicit message and cancel the CSUS
	 * retransmission timer
	 */
	if (dcsp->sd_csus_rexmt_msg) {
		scsp_free_msg(dcsp->sd_csus_rexmt_msg);
		dcsp->sd_csus_rexmt_msg = NULL;
	}
	HARP_CANCEL(&dcsp->sd_csus_rexmt_t);

	/*
	 * Free any entries on the CSU Request retransmission queue
	 */
	for (rxp = dcsp->sd_csu_rexmt; rxp; rxp = rx_next) {
		rx_next = rxp->sr_next;
		HARP_CANCEL(&rxp->sr_t);
		for (csap = rxp->sr_csa; csap; csap = next_csap) {
			next_csap = csap->next;
			SCSP_FREE_CSA(csap);
		}
		UNLINK(rxp, Scsp_csu_rexmt, dcsp->sd_csu_rexmt,
				sr_next);
		UM_FREE(rxp);
	}
}
Exemple #2
0
void clear_news( bool sMatch, int nCount )
{
    int                     nCurrent = 1;
    NEWS_DATA              *news;

    if ( sMatch == FALSE ) {
        while ( ( news = first_news ) != NULL ) {
            STRFREE( news->data );
            UNLINK( news, first_news, last_news, next, prev );
            DISPOSE( news );
        }
    }
    else {
        for ( news = first_news; news != NULL; news = news->next ) {
            if ( nCount == nCurrent ) {
                STRFREE( news->data );
                UNLINK( news, first_news, last_news, next, prev );
                DISPOSE( news );
                break;
            }
            else
                nCurrent++;
        }
    }
}
Exemple #3
0
void dispose_ban( BAN_DATA * pban, int type )
{
    if( !pban )
        return;

    if( type != BAN_SITE && type != BAN_CLASS && type != BAN_RACE )
    {
        bug( "%s: Unknown Ban Type %d.", __func__, type );
        return;
    }

    switch ( type )
    {
    case BAN_SITE:
        UNLINK( pban, first_ban, last_ban, next, prev );
        break;
    case BAN_CLASS:
        UNLINK( pban, first_ban_class, last_ban_class, next, prev );
        break;
    case BAN_RACE:
        UNLINK( pban, first_ban_race, last_ban_race, next, prev );
        break;
    }
    free_ban( pban );
}
static int
testCreateFromFile ()
{
  struct GNUNET_CRYPTO_RsaPrivateKey *key;
  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded p1;
  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded p2;

  key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE);
  GNUNET_assert (NULL != key);
  GNUNET_CRYPTO_rsa_key_get_public (key, &p1);
  GNUNET_CRYPTO_rsa_key_free (key);
  key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE);
  GNUNET_assert (NULL != key);
  GNUNET_CRYPTO_rsa_key_get_public (key, &p2);
  GNUNET_assert (0 == memcmp (&p1, &p2, sizeof (p1)));
  GNUNET_CRYPTO_rsa_key_free (key);
  GNUNET_assert (0 == UNLINK (KEYFILE));
  key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE);
  GNUNET_assert (NULL != key);
  GNUNET_CRYPTO_rsa_key_get_public (key, &p2);
  GNUNET_assert (0 != memcmp (&p1, &p2, sizeof (p1)));
  GNUNET_CRYPTO_rsa_key_free (key);
  GNUNET_assert (0 == UNLINK (KEYFILE));
  return GNUNET_OK;
}
Exemple #5
0
void extract_char(Character *ch, bool fPull)
{

    for (Object * obj_next, *obj = ch->carrying; obj != NULL;
            obj = obj_next)
    {
        obj_next = obj->next_content;
        extract_obj(obj);
    }

    if (ch->inRoom != NULL) {
        char_from_room(ch);
    }
    /*
     * Death room is set in the clan tabe now
     */

    if (!fPull)
    {
        char_to_room(ch, get_room_by_id(DEFAULT_ROOM));
        return;
    }
    UNLINK(first_character, Character, ch, next);

    if (ch->pc) {
        UNLINK(first_player, Character, ch, next_player);
    }
    destroy_char(ch);
}
Exemple #6
0
static void close_archive(FILE *archfp, FILE *outfp, FILE *dupfp) {
	int last_errno;
	
	if (fclose(archfp) != 0) {
		note_archive_failure(outfp, last_errno = errno);
		note_archive_failure(dupfp, last_errno);
		if (outfp != stderr && dupfp != stderr)
			note_archive_failure(stderr, last_errno);
		return;
	}
	UNLINK(chkpnt_cfn);
	UNLINK(chkpnt_tfn);
}
Exemple #7
0
static int
testReadWrite ()
{
  char tmp[100 + 1];
  int ret;

  if (strlen (TESTSTRING) !=
      GNUNET_DISK_fn_write (".testfile", TESTSTRING, strlen (TESTSTRING),
                            GNUNET_DISK_PERM_USER_READ |
                            GNUNET_DISK_PERM_USER_WRITE))
    return 1;
  if (GNUNET_OK != GNUNET_DISK_file_test (".testfile"))
    return 1;
  ret = GNUNET_DISK_fn_read (".testfile", tmp, sizeof (tmp) - 1);
  if (ret < 0)
  {
    FPRINTF (stderr, "Error reading file `%s' in testReadWrite\n", ".testfile");
    return 1;
  }
  tmp[ret] = '\0';
  if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1))
  {
    FPRINTF (stderr, "Error in testReadWrite: *%s* != *%s* for file %s\n", tmp,
             TESTSTRING, ".testfile");
    return 1;
  }
  GNUNET_DISK_file_copy (".testfile", ".testfile2");
  memset (tmp, 0, sizeof (tmp));
  ret = GNUNET_DISK_fn_read (".testfile2", tmp, sizeof (tmp) - 1);
  if (ret < 0)
  {
    FPRINTF (stderr, "Error reading file `%s' in testReadWrite\n",
             ".testfile2");
    return 1;
  }
  tmp[ret] = '\0';
  if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1))
  {
    FPRINTF (stderr, "Error in testReadWrite: *%s* != *%s* for file %s\n", tmp,
             TESTSTRING, ".testfile2");
    return 1;
  }

  GNUNET_break (0 == UNLINK (".testfile"));
  GNUNET_break (0 == UNLINK (".testfile2"));
  if (GNUNET_NO != GNUNET_DISK_file_test (".testfile"))
    return 1;

  return 0;
}
Exemple #8
0
void CTB_unlink(char *name)
{
    char str[MAXPATH], *p = ctb_last_punct(name);

    if (p)
        *p = '\0';

    STRCPY(str, name);
    STRCAT(str, ".CTB");
    UNLINK(str);
    STRCPY(str, name);
    STRCAT(str, ".IND");
    UNLINK(str);
    return;
}
Exemple #9
0
void do_remcontract( CHAR_DATA * ch, char *argument )
{
   CONTRACT_DATA *contract;
   CONTRACT_DATA *scontract = NULL;

   if( argument[0] == '\0' )
   {
      send_to_char( "&RSyntax: remcontract <target name>\n\r", ch );
      return;
   }

   for( contract = ch->first_contract; contract; contract = contract->next_in_contract )
   {
      if( !str_cmp( contract->target, argument ) )
      {
         scontract = contract;
         break;
      }
   }

   if( !scontract || scontract == NULL )
   {
      send_to_char( "No such target.\n\r", ch );
      return;
   }

   STRFREE( scontract->target );
   UNLINK( scontract, ch->first_contract, ch->last_contract, next_in_contract, prev_in_contract );
   DISPOSE( scontract );

   send_to_char( "Contract removed.\n\r", ch );
   return;

}
void CGridDlg::OnBnClickedButtonDiagram() {
  if(!validate()) return;

  windowToValue();
  const GridParameters v = getCurrentValue();
  PearlDiagram diagram;
  PixRect *tmp = v.calculateImage(getImage(), &diagram);
  SAFEDELETE(tmp);

  const String dumpFileName = createTempFileName(_T("txt"));
  FILE *f = NULL;
  try {
    const String dstr = diagram.toString();
    f = MKFOPEN(dumpFileName,_T("w"));

    _ftprintf(f, _T("%s"), dstr.cstr());
    fclose(f); f = NULL;

    ExternProcess::run(false, _T("c:\\windows\\system32\\notepad.exe"), dumpFileName.cstr(), NULL);
    UNLINK(dumpFileName);
  } catch (Exception e) {
    if(f) { fclose(f); f = NULL; }
    showException(e);
  }
}
int
main (int argc, char *argv[])
{
  int ret;

  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-hostlist-peer-1");
  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-hostlist-peer-2");
  GNUNET_log_setup ("test-gnunet-daemon-hostlist",
                    "WARNING",
                    NULL);
#if !WINDOWS
  system ("gnunet-peerinfo -s -c test_learning_adv_peer.conf > /dev/null");
  system ("gnunet-peerinfo -s -c test_learning_learn_peer.conf > /dev/null");
#else
  system ("gnunet-peerinfo -s -c test_learning_adv_peer.conf > NUL");
  system ("gnunet-peerinfo -s -c test_learning_learn_peer.conf > NUL");
#endif
  ret = check ();
  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-hostlist-peer-1");
  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-hostlist-peer-2");
  if (GNUNET_YES == GNUNET_DISK_file_test ("hostlists_learn_peer.file"))
  {
    if (0 == UNLINK ("hostlists_learn_peer.file"))
      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                  "Hostlist file hostlists_learn_peer.file was removed\n");
  }
  return ret;
}
Exemple #12
0
PRIVATE void xlog_unlink(xlog_s *xp)
{
	xlog_s *server = xp->xl_use ;

	/*
	 * Step 1: remove from server chain
	 */
	if ( server != XLOG_NULL )
	{
		if ( server->xl_clients == xp )
			if ( NEXT( xp, xl_other_users ) == xp )
				server->xl_clients = XLOG_NULL ;
			else
				server->xl_clients = NEXT( xp, xl_other_users ) ;
		else
			UNLINK( xp, xl_other_users ) ;
	}

	/*
	 * Step 2: If we have users, clear their link to us.
	 */
	if ( xp->xl_clients != NULL )
	{
		xlog_s *xp2 = xp->xl_clients ;

		do
		{
			xp2->xl_use = XLOG_NULL ;
			xp2 = NEXT( xp2, xl_other_users ) ;
		}
		while ( xp2 != xp->xl_clients ) ;
	}
}
Exemple #13
0
static void
task_finished(isc_task_t *task) {
	isc_taskmgr_t *manager = task->manager;

	REQUIRE(EMPTY(task->events));
	REQUIRE(EMPTY(task->on_shutdown));
	REQUIRE(task->references == 0);
	REQUIRE(task->state == task_state_done);

	XTRACE("task_finished");

	LOCK(&manager->lock);
	UNLINK(manager->tasks, task, link);
#ifdef ISC_PLATFORM_USETHREADS
	if (FINISHED(manager)) {
		/*
		 * All tasks have completed and the
		 * task manager is exiting.  Wake up
		 * any idle worker threads so they
		 * can exit.
		 */
		BROADCAST(&manager->work_available);
	}
#endif /* ISC_PLATFORM_USETHREADS */
	UNLOCK(&manager->lock);

	DESTROYLOCK(&task->lock);
	task->magic = 0;
	isc_mem_put(manager->mctx, task, sizeof(*task));
}
Exemple #14
0
static DWORD
VMCABackupFiles(
    PCSTR pszBaseFilePath
    )
{
    DWORD dwError = ERROR_SUCCESS;
    const DWORD MAX_NUMBER_OF_BAKUPS = 32;
    struct STAT st = { 0 };
    DWORD dwCounter;

    PSTR pszDestFile = NULL;
    PSTR pszSourceFile = NULL;

    for (dwCounter = MAX_NUMBER_OF_BAKUPS; dwCounter > 0; --dwCounter)
    {
        dwError = VMCAAllocateStringPrintfA(
                              &pszDestFile,
                              "%s.%d",
                              pszBaseFilePath,
                              dwCounter);
        BAIL_ON_ERROR(dwError);

        if(STAT(pszDestFile, &st) == ERROR_SUCCESS ) 
        {
            UNLINK(pszDestFile);
        }

        dwError = VMCAAllocateStringPrintfA(
                              &pszSourceFile,
                              "%s.%d",
                              pszBaseFilePath,
                              dwCounter - 1);
        BAIL_ON_ERROR(dwError);

        RENAME(pszSourceFile, pszDestFile);

        VMCA_SAFE_FREE_STRINGA(pszDestFile);
        VMCA_SAFE_FREE_STRINGA(pszSourceFile);

        pszDestFile = NULL;
        pszSourceFile = NULL;
    }

    VMCA_SAFE_FREE_STRINGA(pszDestFile);

    dwError = VMCAAllocateStringPrintfA(
                          &pszDestFile,
                          "%s.%d",
                          pszBaseFilePath,
                          0);
    BAIL_ON_ERROR(dwError);

    RENAME(pszBaseFilePath, pszDestFile);

error:
    VMCA_SAFE_FREE_STRINGA(pszDestFile);
    VMCA_SAFE_FREE_STRINGA(pszSourceFile);

    return dwError;
}
Exemple #15
0
Fichier : TERM.CPP Projet : ems/TMS
void MatchGraph::UNPAIR_ALL ()
{
    long u;

    for (v=1; v <= U; ++v) {
	if (BASE[(int)v] != v || LASTVTX[(int)v] == v)
	    continue;
	nextu = v;
	NEXTVTX[(int)LASTVTX[(int)nextu]] = DUMMYVERTEX;
	while (1) {
	    u = nextu;
	    nextu = NEXTVTX[(int)nextu];
	    UNLINK (u);
	    if (LASTVTX[(int)u] != u) {
		f = (LASTEDGE[2] == OPPEDGE(e)) ? LASTEDGE[1] : LASTEDGE[2];
		NEXTVTX[(int)LASTVTX[(int)BEND(f)]] = u;
	    }
	    newbase = BMATE (BMATE(u));
	    if (newbase != DUMMYVERTEX && newbase != u) {
		LINK[(int)u] = -DUMMYEDGE;
		REMATCH (newbase, MATE[(int)u]);
	    }
	    while (LASTVTX[(int)nextu] == nextu && nextu != DUMMYVERTEX)
		nextu = NEXTVTX[(int)nextu];
	    if (LASTVTX[(int)nextu] == nextu && nextu == DUMMYVERTEX)
		break;
	}
    }
}
Exemple #16
0
/*
 * Remove less1-connected-components located to the right of
 * the less1-connected-component containing p->point.
 *
 * Undefined behavior if p is the pattern with only one node.
 */
static pattern *remove_end_clumps( pattern *p )
{
  node *n, *n_next;
  pattern *q;

  /*
   * Search for the first node (if any) that lies further right
   * than every circle containing p->point.
   */
  n = p->first_node->next;

  while ( n->position <= p->point->position )
  {
    n = n->less1->next;
    if ( !n )
      return p;
  }

  /*
   * Having found such a node, n, we make a copy of p,
   * and in the copy, kill everything from n onward.
   */
  q = copy_pattern(p);

  q->nodes = n->position;

  for ( n = isom(n,q); n; n = n_next )
  {
    n_next = n->next;
    UNLINK( n, q->first_node, q->last_node, next, prev );
    kill_node( n );
  }

  return q;
}
Exemple #17
0
/*
 * Having successfully marked some points for removal ("successfully" here
 * means that doing so did not force us to mark p->point), make a copy of
 * the pattern, and remove the marked points from it.
 */
static pattern *execute_removal(pattern *p)
{
  node *n, *m, *m_next;
  pattern *q;
  int i;

  q = copy_pattern(p);

  for ( i=0, n=p->first_node, m=q->first_node; n; n = n->next, m = m_next )
  {
    m_next = m->next;

    if ( n->simplify_data == SIMPL_MARKED )
    {
      UNLINK( m, q->first_node, q->last_node, next, prev );
      kill_node( m );
    }
    else
    {
      /*
       * Maintain a running count of how many nodes we DON'T remove,
       * so we can fix the nodecount after the dust settles.
       */
      i++;
    }
  }

  q->nodes = i;

  for ( i = 0, m = q->first_node; m; m = m->next )
    m->position = i++;

  return q;
}
/**
 * Exit point from the plugin.
 *
 * @param cls the plugin context (as returned by "init")
 * @return always NULL
 */
void *
libgnunet_plugin_datastore_sqlite_done (void *cls)
{
  char *fn;
  struct GNUNET_DATASTORE_PluginFunctions *api = cls;
  struct Plugin *plugin = api->cls;

  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
                   "sqlite plugin is done\n");
  fn = NULL;
  if (plugin->drop_on_shutdown)
    fn = GNUNET_strdup (plugin->fn);
  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
                   "Shutting down database\n");
  database_shutdown (plugin);
  plugin->env = NULL;
  GNUNET_free (api);
  if (fn != NULL)
  {
    if (0 != UNLINK (fn))
      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
    GNUNET_free (fn);
  }
  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
                   "sqlite plugin is finished\n");
  return NULL;
}
/* good1() uses the GoodSinkBody in the while loop */
static void good1()
{
    while(1)
    {
        {
            char * filename;
            char tmpl[] = "goodXXXXXX";
            FILE *pFile;
            /* Establish that this is a temporary file and that it should be deleted */
            filename = MKTEMP(tmpl);
            if (filename != NULL)
            {
                pFile = FOPEN(filename, "w");
                if (pFile != NULL)
                {
                    fprintf(pFile, "Temporary file");
                    fclose(pFile);
                    /* FIX: Unlink the temporary file */
                    UNLINK(filename); /* EXPECTED INCIDENTAL: CWE367 TOCTOU - This POSIX API is essentially insecure by design */
                }
            }
        }
        break;
    }
}
Exemple #20
0
/* Take a qbit off a character */
void remove_qbit( CHAR_DATA * ch, int number )
{
   BIT_DATA *bit;

   if( IS_NPC( ch ) )
      return;

   if( number < 0 || number > MAX_xBITS )
      return;

   if( !ch->pcdata->first_qbit )
      return;

   bit = ch->pcdata->first_qbit;
   while( bit )
   {
      BIT_DATA *tmp;

      if( bit->number == number )
      {
         tmp = bit;
         bit = bit->next;
         UNLINK( tmp, ch->pcdata->first_qbit, ch->pcdata->last_qbit, next, prev );
         DISPOSE( tmp );
      }
      else
         bit = bit->next;
   }
}
/* good1() uses if(GLOBAL_CONST_FIVE!=5) instead of if(GLOBAL_CONST_FIVE==5) */
static void good1()
{
    if(GLOBAL_CONST_FIVE!=5)
    {
        /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
        printLine("Benign, fixed string");
    }
    else
    {
        {
            char * filename;
            char tmpl[] = "goodXXXXXX";
            FILE *pFile;
            /* Establish that this is a temporary file and that it should be deleted */
            filename = MKTEMP(tmpl);
            if (filename != NULL)
            {
                pFile = FOPEN(filename, "w");
                if (pFile != NULL)
                {
                    fprintf(pFile, "Temporary file");
                    fclose(pFile);
                    /* FIX: Unlink the temporary file */
                    UNLINK(filename); /* EXPECTED INCIDENTAL: CWE367 TOCTOU - This POSIX API is essentially insecure by design */
                }
            }
        }
    }
}
void CWE511_Logic_Time_Bomb__w32CompareFileTime_15_bad()
{
    switch(6)
    {
    case 6:
    {
        SYSTEMTIME setTime, currentTime;
        FILETIME setTimeAsFileTime, currentTimeAsFileTime;
        /* Jan 1, 2008 12:00:00 PM */
        setTime.wYear         = 2008; /* Year */
        setTime.wMonth        = 1;    /* January */
        setTime.wDayOfWeek    = 0;    /* Ignored */
        setTime.wDay          = 1;    /* The first of the month */
        setTime.wHour         = 12;   /* 12 PM */
        setTime.wMinute       = 0;    /* 0 minutes into the hour */
        setTime.wSecond       = 0;    /* 0 seconds into the minute */
        setTime.wMilliseconds = 0;    /* 0 milliseconds into the second */
        GetSystemTime(&currentTime);
        /* Must convert to FILETIME for comparison */
        SystemTimeToFileTime(&currentTime, &currentTimeAsFileTime);
        SystemTimeToFileTime(&setTime, &setTimeAsFileTime);
        /* FLAW: After a certain date, delete a file */
        if (CompareFileTime(&currentTimeAsFileTime, &setTimeAsFileTime) == 1)
        {
            UNLINK("important_file.txt");
        }
    }
    break;
    default:
        /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
        printLine("Benign, fixed string");
        break;
    }
}
Exemple #23
0
static mrb_value
mrb_file_s_rename(mrb_state *mrb, mrb_value obj)
{
  mrb_value from, to;
  char *src, *dst;

  mrb_get_args(mrb, "SS", &from, &to);
  src = mrb_locale_from_utf8(mrb_string_value_cstr(mrb, &from), -1);
  dst = mrb_locale_from_utf8(mrb_string_value_cstr(mrb, &to), -1);
  if (rename(src, dst) < 0) {
#if defined(_WIN32) || defined(_WIN64)
    if (CHMOD(dst, 0666) == 0 && UNLINK(dst) == 0 && rename(src, dst) == 0) {
      mrb_locale_free(src);
      mrb_locale_free(dst);
      return mrb_fixnum_value(0);
    }
#endif
    mrb_locale_free(src);
    mrb_locale_free(dst);
    mrb_sys_fail(mrb, mrb_str_to_cstr(mrb, mrb_format(mrb, "(%S, %S)", from, to)));
  }
  mrb_locale_free(src);
  mrb_locale_free(dst);
  return mrb_fixnum_value(0);
}
Exemple #24
0
static void
test_reopen(const char *path)
{
	PMEMlogpool *log1 = pmemlog_create(path, PMEMLOG_MIN_POOL,
			S_IWUSR | S_IRUSR);
	if (!log1)
		FATAL("!create");

	PMEMlogpool *log2 = pmemlog_open(path);
	if (log2)
		FATAL("pmemlog_open should not succeed");

	if (errno != EWOULDBLOCK)
		FATAL("!pmemlog_open failed but for unexpected reason");

	pmemlog_close(log1);

	log2 = pmemlog_open(path);
	if (!log2)
		FATAL("pmemlog_open should succeed after close");

	pmemlog_close(log2);

	UNLINK(path);
}
void CWE511_Logic_Time_Bomb__time_12_bad()
{
    if(globalReturnsTrueOrFalse())
    {
        {
            time_t currentTime;
            /* FLAW: After a certain date, delete a file */
            time(&currentTime);
            if (currentTime > TIME_CHECK)
            {
                UNLINK("important_file.txt");
            }
        }
    }
    else
    {
        {
            time_t currentTime;
            /* FIX: After a certain date, print to the console */
            time(&currentTime);
            if (currentTime > TIME_CHECK)
            {
                printLine("Happy New Year!");
            }
        }
    }
}
UINT AviConverter::run() {
  try {
    CPicture picture;
    picture.load(m_nameArray[0]);
    const CSize imageSize = picture.getSize();

    HDC screenDC = getScreenDC();
    m_dc     = CreateCompatibleDC(screenDC);
    m_bitmap = CreateCompatibleBitmap(screenDC, imageSize.cx, imageSize.cy);
    DeleteDC(screenDC);
    DWORD codec = 0; // mmioFOURCC('w','m','v',' ');

    if(ACCESS(m_outFileName, 0) == 0) {
      UNLINK(m_outFileName);
    }
    CAviFile aviFile(m_outFileName, true, codec, m_framesPerSecond);

    for(m_index = 0; m_index < (int)m_nameArray.size(); m_index += m_useEvery) {
      if(isInterrupted()) {
        throwException(_T("Interrupted by user"));
      }
      picture.load(m_nameArray[m_index]);
      HGDIOBJ oldGDI = SelectObject(m_dc, m_bitmap);
      picture.show(m_dc);
      SelectObject(m_dc, oldGDI);
      aviFile.appendNewFrame(m_bitmap);
    }
  } catch(Exception e) {
    m_ok  = false;
    m_msg = e.what();
  }
  return 0;
}
Exemple #27
0
static void
destroy(isc__timer_t *timer) {
	isc__timermgr_t *manager = timer->manager;

	/*
	 * The caller must ensure it is safe to destroy the timer.
	 */

	LOCK(&manager->lock);

	(void)isc_task_purgerange(timer->task,
				  timer,
				  ISC_TIMEREVENT_FIRSTEVENT,
				  ISC_TIMEREVENT_LASTEVENT,
				  NULL);
	deschedule(timer);
	UNLINK(manager->timers, timer, link);

	UNLOCK(&manager->lock);

	isc_task_detach(&timer->task);
	DESTROYLOCK(&timer->lock);
	timer->common.impmagic = 0;
	timer->common.magic = 0;
	isc_mem_put(manager->mctx, timer, sizeof(*timer));
}
void CWE511_Logic_Time_Bomb__w32CompareFileTime_10_bad()
{
    if(globalTrue)
    {
        {
            SYSTEMTIME setTime, currentTime;
            FILETIME setTimeAsFileTime, currentTimeAsFileTime;
            /* Jan 1, 2008 12:00:00 PM */
            setTime.wYear         = 2008; /* Year */
            setTime.wMonth        = 1;    /* January */
            setTime.wDayOfWeek    = 0;    /* Ignored */
            setTime.wDay          = 1;    /* The first of the month */
            setTime.wHour         = 12;   /* 12 PM */
            setTime.wMinute       = 0;    /* 0 minutes into the hour */
            setTime.wSecond       = 0;    /* 0 seconds into the minute */
            setTime.wMilliseconds = 0;    /* 0 milliseconds into the second */
            GetSystemTime(&currentTime);
            /* Must convert to FILETIME for comparison */
            SystemTimeToFileTime(&currentTime, &currentTimeAsFileTime);
            SystemTimeToFileTime(&setTime, &setTimeAsFileTime);
            /* FLAW: After a certain date, delete a file */
            if (CompareFileTime(&currentTimeAsFileTime, &setTimeAsFileTime) == 1)
            {
                UNLINK("important_file.txt");
            }
        }
    }
}
void gtmsecshr_sock_cleanup(int caller)
{
	int			save_errno;
	struct sockaddr_un	*sock_ptr;

	/* Close the secshr client socket */
	if (-1 != gtmsecshr_sockfd)
	{
		close(gtmsecshr_sockfd);
		gtmsecshr_sockfd = -1;
	}

	/* do the unlink */

	sock_ptr = (CLIENT == caller) ? &gtmsecshr_cli_sock_name : &gtmsecshr_sock_name;

	if (('\0' != sock_ptr->sun_path[0]) && (-1 == UNLINK(sock_ptr->sun_path))
		&& (ENOENT != errno))
	{
		save_errno = errno;
		send_msg(VARLSTCNT(12) ERR_GTMSECSHR, 1, process_id, ERR_TEXT, 2, RTS_ERROR_TEXT("unlinking socket"),
			ERR_TEXT, 2, RTS_ERROR_STRING(sock_ptr->sun_path), save_errno);
	}
	sock_ptr->sun_path[0] = '\0';	/* Even if error unlinking since it is useless now */

	gtmsecshr_sock_init_done = FALSE;
}
Exemple #30
0
/*
 * Process a CA message
 *
 * Arguments:
 *	dcsp	pointer to a DCS control block for the neighbor
 *	cap	pointer to the CA part of the received message
 *
 * Returns:
 *	none
 *
 */
void
scsp_process_ca(Scsp_dcs* dcsp, Scsp_ca *cap)
{
	Scsp_csa	*csap, *next_csap;
	Scsp_cse	*csep;
	Scsp_server	*ssp = dcsp->sd_server;

	/*
	 * Process CSAS records from the CA message
	 */
	for (csap = cap->ca_csa_rec; csap; csap = next_csap) {
		next_csap = csap->next;
		SCSP_LOOKUP(ssp, &csap->key, csep);
		if (!csep || (scsp_cmp_id(&csap->oid,
					&csep->sc_oid) == 0 &&
				csap->seq > csep->sc_seq)) {
			/*
			 * CSAS entry not in cache or more
			 * up to date than cache, add it to CRL
			 */
			UNLINK(csap, Scsp_csa, cap->ca_csa_rec, next);
			LINK2TAIL(csap, Scsp_csa, dcsp->sd_crl, next);
		}
	}
}