Ignore:
Timestamp:
Jul 11, 2012, 9:02:13 PM (12 years ago)
Author:
katerina
Message:

Fix for tickets #301 and #302 (problems with the windows registry check).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_registry.c

    r335 r403  
    181181          if (status != 0)
    182182            {
    183               char  errbuf[256];
     183              char  errbuf[512];
     184              char  *p;
    184185              regerror(status, &(newkey->preg), errbuf, sizeof(errbuf));
     186
     187              sl_strlcat(errbuf, ": ", sizeof(errbuf));
     188              p = sh_util_safe_name_keepspace(s);
     189              sl_strlcat(errbuf, p, sizeof(errbuf));
     190              SH_FREE(p);
     191
    185192              SH_MUTEX_LOCK(mutex_thread_nolog);
    186193              sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGEN,
     
    743750          doUpdate = S_TRUE;
    744751        }
     752
    745753    }
    746754 
    747   if ( sh.flag.checkSum == SH_CHECK_INIT || doUpdate == S_TRUE )
     755  if ( sh.flag.checkSum == SH_CHECK_INIT || doUpdate == S_TRUE /* change detected */ )
    748756    {
    749757      struct store2db save;
     
    767775    }
    768776
    769   if (tPath)
    770     sh_hash_set_visited (tPath);
    771   else
    772     sh_hash_set_visited (path);
     777  /* Without this, freshly updated entries would get deleted
     778   * as 'not seen'.
     779   */
     780  if (sh.flag.checkSum != SH_CHECK_INIT)
     781    {
     782      if (tPath)
     783        sh_hash_set_visited (tPath);
     784      else
     785        sh_hash_set_visited (path);
     786    }
    773787
    774788  if (tPath)
     
    806820{
    807821  HKEY hTestKey;
     822  LONG qError;
    808823  char * newpath;
    809824  size_t len;
     
    836851  snprintf(newpath, len, "%s\\%s", path, subkey);
    837852 
    838   if( RegOpenKeyEx( key,
    839                     subkey,
    840                     0,
    841                     (KEY_READ | view),
    842                     &hTestKey) == ERROR_SUCCESS
    843       )
     853  qError = RegOpenKeyEx( key,
     854                         subkey,
     855                         0,
     856                         (KEY_READ | view),
     857                         &hTestKey);
     858
     859
     860  if (qError == ERROR_SUCCESS)
    844861    {
    845862      QueryKey(hTestKey, newpath, len-1, isSingle);
     
    850867    {
    851868      /* Error message */
    852       char  * tmp    = sh_util_safe_name (newpath);
    853       size_t  tlen   = sl_strlen(tmp);
    854      
     869      LPVOID lpMsgBuf;
     870 
     871      char  * tmp     = sh_util_safe_name (newpath);
     872      size_t  tlen    = sl_strlen(tmp);
     873
    855874      if (SL_TRUE == sl_ok_adds(64, tlen))
    856875        {
    857           char * errbuf = SH_ALLOC(64 + tlen);
    858           sl_snprintf(errbuf, 64+tlen, _("Failed to open key %s"), tmp);
    859          
    860           SH_MUTEX_LOCK(mutex_thread_nolog);
    861           sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
    862                           errbuf, _("CheckThisSubkey"));
    863           SH_MUTEX_UNLOCK(mutex_thread_nolog);
    864          
    865           SH_FREE(errbuf);
    866         }
    867       sh_reg_add_ign (tmp);
     876          char * errbuf;
     877          size_t elen;
     878
     879          tlen += 64;
     880
     881          elen = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
     882                               FORMAT_MESSAGE_FROM_SYSTEM |
     883                               FORMAT_MESSAGE_IGNORE_INSERTS,
     884                               NULL,
     885                               qError,
     886                               MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
     887                               (LPTSTR) &lpMsgBuf,
     888                               0, NULL );
     889
     890          if (elen > 0 && SL_TRUE == sl_ok_adds(elen, tlen))
     891            {
     892              tlen += elen;
     893
     894              errbuf = SH_ALLOC(elen + tlen);
     895              sl_snprintf(errbuf, 64+tlen, _("Failed to open key %s: %s"),
     896                          tmp, lpMsgBuf);
     897              LocalFree(lpMsgBuf);
     898
     899              SH_MUTEX_LOCK(mutex_thread_nolog);
     900              sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
     901                              errbuf, _("CheckThisSubkey"));
     902              SH_MUTEX_UNLOCK(mutex_thread_nolog);
     903             
     904              SH_FREE(errbuf);
     905            }
     906        }
     907      sh_reg_add_ign (newpath);
    868908      SH_FREE(tmp);
    869909    }
     
    880920  char path[20] = "";
    881921  int pos = 0;
    882   int retval = -1;
    883922 
    884923  if      (0 == strncmp(key, _("HKEY_CLASSES_ROOT"), 17))
Note: See TracChangeset for help on using the changeset viewer.