MCPcopy Index your code
hub / github.com/MapServer/MapServer / msDecryptStringTokens

Function msDecryptStringTokens

mapcrypto.c:427–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425 **********************************************************************/
426
427char *msDecryptStringTokens(mapObj *map, const char *in)
428{
429 char *outbuf, *out;
430
431 if (map == NULL)
432 {
433 msSetError(MS_MISCERR, "NULL MapObj.", "msLoadEncryptionKey()");
434 return NULL;
435 }
436
437 /* Start with a copy of the string. Decryption can only result in
438 * a string with the same or shorter length */
439 if ((outbuf = (char *)malloc((strlen(in)+1)*sizeof(char))) == NULL)
440 {
441 msSetError(MS_MEMERR, NULL, "msDecryptStringTokens()");
442 return NULL;
443 }
444 out = outbuf;
445
446 while(*in != '\0')
447 {
448 if (*in == '{')
449 {
450 /* Possibly beginning of a token, look for closing bracket
451 ** and make sure all chars in between are valid hex encoding chars
452 */
453 const char *pszStart, *pszEnd;
454 int valid_token = MS_FALSE;
455
456 pszStart = in+1;
457 if ( (pszEnd = strchr(pszStart, '}')) != NULL &&
458 pszEnd - pszStart > 1)
459 {
460 const char *pszTmp;
461 valid_token = MS_TRUE;
462 for(pszTmp = pszStart; pszTmp < pszEnd; pszTmp++)
463 {
464 if (!isxdigit(*pszTmp))
465 {
466 valid_token = MS_FALSE;
467 break;
468 }
469 }
470 }
471
472 if (valid_token)
473 {
474 /* Go ahead and decrypt the token */
475 char *pszTmp;
476
477 /* Make sure encryption key is loaded. We do this here instead
478 * of at the beginning of the function to avoid loading the
479 * key unless ready necessary. This is a very cheap call if
480 * the key is already loaded
481 */
482 if (msLoadEncryptionKey(map) != MS_SUCCESS)
483 return NULL;
484

Callers 13

msPrepareWMSLayerRequestFunction · 0.85
msOGRFileOpenFunction · 0.85
msPostGISLayerOpenFunction · 0.85
msRasterQueryByRectFunction · 0.85
msRASTERLayerGetExtentFunction · 0.85
msWCSGetCoverageMetadataFunction · 0.85
msPOSTGRESQLJoinConnectFunction · 0.85
mainFunction · 0.85
mapjoin.cFile · 0.85
msMSSQL2008LayerOpenFunction · 0.85
msSDELayerOpenFunction · 0.85
msSplitLoginFunction · 0.85

Calls 4

msSetErrorFunction · 0.85
msLoadEncryptionKeyFunction · 0.85
strlcpyFunction · 0.85
msDecryptStringWithKeyFunction · 0.85

Tested by

no test coverage detected