CVE-2012-0037

Enforce entity loading policy in raptor_libxml_resolveEntity
and raptor_libxml_getEntity by checking for file URIs and network URIs.

Add RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES / loadExternalEntities for
turning on loading of XML external entity loading, disabled by default.

This affects all the parsers that use SAX2: rdfxml, rss-tag-soup (and
aliases) and rdfa.
raptor_object_options_set_option(raptor_object_options *options,
                                 raptor_option option,
                                 const char* string, int integer)
{
  if(!raptor_option_is_valid_for_area(option, options->area))
    return 1;
  
  if(raptor_option_value_is_numeric(option)) {
    /* numeric options */
    if(string)
      integer = atoi((const char*)string);

    options->options[(int)option].integer = integer;
    return 0;
  } else {
    /* non-numeric options */
    char *string_copy;
    size_t len = 0;
    
    if(string)
      len = strlen((const char*)string);
    string_copy = RAPTOR_MALLOC(char*, len + 1);
    if(!string_copy)
      return 1;
  
    if(len)
      memcpy(string_copy, string, len);
    string_copy[len] = '\0';
    
    options->options[(int)option].string = string_copy;
  }
  
  return 0;
}

raptor_object_options_set_option(raptor_object_options *options,
                                 raptor_option option,
                                 const char* string, int integer)
{
  if(!raptor_option_is_valid_for_area(option, options->area))
    return 1;
  
  if(raptor_option_value_is_numeric(option)) {
    /* numeric options */
    if(string)
      integer = atoi((const char*)string);

    options->options[(int)option].integer = integer;
    return 0;
  } else {
    /* non-numeric options */
    char *string_copy;
    size_t len = 0;
    
    if(string)
      len = strlen((const char*)string);
    string_copy = RAPTOR_MALLOC(char*, len + 1);
    if(!string_copy)
      return 1;
  
    if(len)
      memcpy(string_copy, string, len);
    string_copy[len] = '\0';
    
    options->options[(int)option].string = string_copy;
  }
  
  return 0;
}
