Parcourir la source

cmLib.c : Attempts to load non-library files now fail silently.

master
kpl_harpo il y a 10 ans
Parent
révision
4712a0ccb2
1 fichiers modifiés avec 14 ajouts et 1 suppressions
  1. 14
    1
      cmLib.c

+ 14
- 1
cmLib.c Voir le fichier

@@ -160,7 +160,20 @@ unsigned  cmLibOpen(  cmLibH_t h, const cmChar_t* libFn )
160 160
 
161 161
   if( _cmLibIsNull(lH) )
162 162
   {
163
-    cmErrMsg(&p->err,kOpenFailLibRC,"Library load failed. System Message: %s", _cmLibSysError() );
163
+    // There is apparently no way to get an error code which indicates that the
164
+    // file load attempt failed because the file was not a shared library - 
165
+    // which should not generate an error message - therefore
166
+    // we must match the end of the the error string returned by dlerror() with 
167
+    // 'invalid ELF header'.
168
+    const char* errMsg = _cmLibSysError();
169
+    const char* s      = "invalid ELF header";
170
+    unsigned    sn      = strlen(s);
171
+    unsigned    mn       = strlen(errMsg);
172
+    if( errMsg!=NULL && mn>sn && strcmp(errMsg+mn-sn,s)==0 )
173
+      cmErrSetRC(&p->err,kOpenFailLibRC ); // signal error but no error message
174
+    else
175
+      cmErrMsg(&p->err,kOpenFailLibRC,"Library load failed. System Message: %s", errMsg );
176
+
164 177
     return cmInvalidId;
165 178
   }
166 179
   

Chargement…
Annuler
Enregistrer