1. 04 Apr, 2017 1 commit
    • config_file: handle errors other than OOM while parsing section headers · 4467aeac
      The current code in `parse_section_header_ext` is only prepared to
      properly handle out-of-memory conditions for the `git_buf` structure.
      While very unlikely and probably caused by a programming error, it is
      also possible to run into error conditions other than out-of-memory
      previous to reaching the actual parsing loop. In these cases, we will
      run into undefined behavior as the `rpos` variable is only initialized
      after these triggerable errors, but we use it in the cleanup-routine.
      
      Fix the issue by unifying the function's cleanup code with an
      `end_error` section, which will not use the `rpos` variable.
      Patrick Steinhardt committed
  2. 23 Mar, 2017 2 commits
  3. 21 Mar, 2017 1 commit
  4. 17 Feb, 2017 2 commits
  5. 29 Dec, 2016 1 commit
  6. 06 Oct, 2016 1 commit
  7. 28 Mar, 2016 1 commit
  8. 21 Mar, 2016 1 commit
  9. 11 Mar, 2016 1 commit
    • config_file: handle error when trying to lock strmap · 836447e5
      Accessing the current values map is handled through the
      `refcounder_strmap_take` function, which first acquires a mutex
      before accessing its values. While this assures everybody is
      trying to access the values with the mutex only we do not check
      if the locking actually succeeds.
      
      Fix the issue by checking if acquiring the lock succeeds and
      returning `NULL` if we encounter an error. Adjust callers.
      Patrick Steinhardt committed
  10. 10 Mar, 2016 1 commit
    • config_file: handle missing quotation marks in section header · e126bc95
      When parsing a section header we expect something along the
      format of '[section "subsection"]'. When a section is
      mal-formated and is entirely missing its quotation marks we catch
      this case by observing that `strchr(line, '"') - strrchr(line,
      '"') = NULL - NULL = 0` and error out. Unfortunately, the error
      message is misleading though, as we state that we are missing the
      closing quotation mark while we in fact miss both quotation
      marks.
      
      Improve the error message by explicitly checking if the first
      quotation mark could be found and, if not, stating that quotation
      marks are completely missing.
      Patrick Steinhardt committed
  11. 30 Oct, 2015 1 commit
  12. 18 Sep, 2015 1 commit
  13. 12 Aug, 2015 2 commits
  14. 29 May, 2015 1 commit
    • git__tolower: a tolower() that isn't dumb · 75a4636f
      Some brain damaged tolower() implementations appear to want to
      take the locale into account, and this may require taking some
      insanely aggressive lock on the locale and slowing down what should
      be the most trivial of trivial calls for people who just want to
      downcase ASCII.
      Edward Thomson committed
  15. 05 May, 2015 1 commit
  16. 04 May, 2015 4 commits
    • config: lock the file for write before reading · 9c26de0f
      When writing a configuration file, we want to take a lock on the
      new file (eg, `config.lock`) before opening the configuration file
      (`config`) for reading so that we can prevent somebody from changing
      the contents underneath us.
      Edward Thomson committed
    • config: write existing lines as-is when rewriting · 2a950c94
      When updating a configuration file, we want to copy the old data
      from the file to preserve comments and funny whitespace, instead
      of writing it in some "canonical" format.  Thus, we keep a
      pointer to the start of the line and the line length to preserve
      these things we don't care to rewrite.
      Edward Thomson committed
    • config: examine whole file when writing · bf99390e
      Previously we would try to be clever when writing the configuration
      file and try to stop parsing (and simply copy the rest of the old
      file) when we either found the value we were trying to write,
      or when we left the section that value was in, the assumption being
      that there was no more work to do.
      
      Regrettably, you can have another section with the same name later
      in the file, and we must cope with that gracefully, thus we read the
      whole file in order to write a new file.
      
      Now, writing a file looks even more than reading.  Pull the config
      parsing out into its own function that can be used by both reading
      and writing the configuration.
      Edward Thomson committed
  17. 23 Apr, 2015 2 commits
  18. 21 Apr, 2015 1 commit
    • git_config_delete: search until last section. · 9a810c5e
      If git_config_delete is to work properly in the presence of duplicate section
      headers, it cannot stop searching at the end of the first matching section, as
      there may be another matching section later.
      When config_write is used for deletion (value = NULL), it may only terminate
      when the desired key is found or there are no sections left to parse.
      Ryan Roden-Corrent committed
  19. 20 Apr, 2015 2 commits
  20. 10 Apr, 2015 1 commit
    • Fix checking of return value for regcomp. · 129022ee
      The regcomp function returns a non-zero value if compilation of
      a regular expression fails. In most places we only check for
      negative values, but positive values indicate an error, as well.
      Fix this tree-wide, fixing a segmentation fault when calling
      git_config_iterator_glob_new with an invalid regexp.
      Patrick Steinhardt committed
  21. 03 Mar, 2015 1 commit
    • config: borrow refcounted references · 9a97f49e
      This changes the get_entry() method to return a refcounted version of
      the config entry, which you have to free when you're done.
      
      This allows us to avoid freeing the memory in which the entry is stored
      on a refresh, which may happen at any time for a live config.
      
      For this reason, get_string() has been forbidden on live configs and a
      new function get_string_buf() has been added, which stores the string in
      a git_buf which the user then owns.
      
      The functions which parse the string value takea advantage of the
      borrowing to parse safely and then release the entry.
      Carlos Martín Nieto committed
  22. 15 Feb, 2015 1 commit
  23. 13 Feb, 2015 3 commits
  24. 12 Feb, 2015 1 commit
  25. 29 Dec, 2014 1 commit
  26. 05 Dec, 2014 1 commit
  27. 03 Nov, 2014 1 commit
  28. 01 Nov, 2014 1 commit
  29. 23 Oct, 2014 2 commits