<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/patch.git/src, branch master</title>
<subtitle>git.savannah.gnu.org: git/patch.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/'/>
<entry>
<title>Pass the correct stat to backup files</title>
<updated>2022-05-10T08:53:04+00:00</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2022-04-06T08:48:35+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/commit/?id=c835ecc67b7e37c0d0b7dd7e032209fdaa285808'/>
<id>c835ecc67b7e37c0d0b7dd7e032209fdaa285808</id>
<content type='text'>
The last case to call output_file() in the main loop is
    output_file (outname, NULL, &amp;tmpoutst, NULL, NULL,
                 file_type | 0, backup);
and this essentially means to create a backup file (where to=NULL)
only if backup=true, and does nothing else.

And, in the current code, the passed file stat (&amp;tmpoutst) is a file
stat of the temporary file that has been processed, not the original
file (outname) to be backed up.  When the backup is performed
immediately, this is no big problem.  However, output_file() may
schedule the deferred handling, and the given file may be backed up at
a later point.  The problem is that create_backup() tries to avoid the
backup of the same file twice, and it checks the given stat i-node
number in the hash list.  Since it's a stat of a temporary file, the
same i-node number may be reused once a temp file is deleted and
another is created.  This results in a false-positive detection of the
already existing file, eventually missing a backup file.

This patch attempts to address the issue:
- Modify the condition for better understanding, clearly indicating
  that the code there is for creating a backup file
- Pass the stat of the original file instead of a temporary file

BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1198106
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Signed-off-by: Jean Delvare &lt;jdelvare@suse.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The last case to call output_file() in the main loop is
    output_file (outname, NULL, &amp;tmpoutst, NULL, NULL,
                 file_type | 0, backup);
and this essentially means to create a backup file (where to=NULL)
only if backup=true, and does nothing else.

And, in the current code, the passed file stat (&amp;tmpoutst) is a file
stat of the temporary file that has been processed, not the original
file (outname) to be backed up.  When the backup is performed
immediately, this is no big problem.  However, output_file() may
schedule the deferred handling, and the given file may be backed up at
a later point.  The problem is that create_backup() tries to avoid the
backup of the same file twice, and it checks the given stat i-node
number in the hash list.  Since it's a stat of a temporary file, the
same i-node number may be reused once a temp file is deleted and
another is created.  This results in a false-positive detection of the
already existing file, eventually missing a backup file.

This patch attempts to address the issue:
- Modify the condition for better understanding, clearly indicating
  that the code there is for creating a backup file
- Pass the stat of the original file instead of a temporary file

BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1198106
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Signed-off-by: Jean Delvare &lt;jdelvare@suse.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gnulib: update to latest</title>
<updated>2020-05-14T12:01:13+00:00</updated>
<author>
<name>Andreas Gruenbacher</name>
<email>agruen@gnu.org</email>
</author>
<published>2020-05-14T10:36:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/commit/?id=099394003477b83c2eb4be07fd0173d6e696cf4e'/>
<id>099394003477b83c2eb4be07fd0173d6e696cf4e</id>
<content type='text'>
* bootstrap: Update.
* bootstrap.conf (gnulib_modules): Replace getdate with parse-datetime, malloc
with malloc-gnu, and realloc with realloc-gnu.
* src/patch.c (main): Function find_backup_file_name has gained a new dir_fd
argument.
* src/util.c (create_backup): Likewise.
(fetchname): Function get_date has been renamed to parse_datetime.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* bootstrap: Update.
* bootstrap.conf (gnulib_modules): Replace getdate with parse-datetime, malloc
with malloc-gnu, and realloc with realloc-gnu.
* src/patch.c (main): Function find_backup_file_name has gained a new dir_fd
argument.
* src/util.c (create_backup): Likewise.
(fetchname): Function get_date has been renamed to parse_datetime.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix failed assertion 'outstate-&gt;after_newline'</title>
<updated>2019-07-15T23:16:28+00:00</updated>
<author>
<name>Andreas Gruenbacher</name>
<email>agruen@gnu.org</email>
</author>
<published>2019-07-15T23:16:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/commit/?id=76e775847f4954b63dc72afe34d9d921c6688b31'/>
<id>76e775847f4954b63dc72afe34d9d921c6688b31</id>
<content type='text'>
The assertion triggers when the -o FILE option is used, more than one output
file is written into FILE, and one of those files (except the last one) ends in
the middle of a line.
* src/patch.c (main): Fix the case described above.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The assertion triggers when the -o FILE option is used, more than one output
file is written into FILE, and one of those files (except the last one) ends in
the middle of a line.
* src/patch.c (main): Fix the case described above.
</pre>
</div>
</content>
</entry>
<entry>
<title>Avoid invalid memory access in context format diffs</title>
<updated>2019-07-15T17:53:50+00:00</updated>
<author>
<name>Andreas Gruenbacher</name>
<email>agruen@gnu.org</email>
</author>
<published>2019-07-15T17:10:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/commit/?id=15b158db3ae11cb835f2eb8d2eb48e09d1a4af48'/>
<id>15b158db3ae11cb835f2eb8d2eb48e09d1a4af48</id>
<content type='text'>
* src/pch.c (another_hunk): Avoid invalid memory access in context format
diffs.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* src/pch.c (another_hunk): Avoid invalid memory access in context format
diffs.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't follow symlinks unless --follow-symlinks is given</title>
<updated>2019-07-15T17:53:27+00:00</updated>
<author>
<name>Andreas Gruenbacher</name>
<email>agruen@gnu.org</email>
</author>
<published>2019-07-15T14:21:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/commit/?id=dce4683cbbe107a95f1f0d45fabc304acfb5d71a'/>
<id>dce4683cbbe107a95f1f0d45fabc304acfb5d71a</id>
<content type='text'>
* src/inp.c (plan_a, plan_b), src/util.c (copy_to_fd, copy_file,
append_to_file): Unless the --follow-symlinks option is given, open files with
the O_NOFOLLOW flag to avoid following symlinks.  So far, we were only doing
that consistently for input files.
* src/util.c (create_backup): When creating empty backup files, (re)create them
with O_CREAT | O_EXCL to avoid following symlinks in that case as well.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* src/inp.c (plan_a, plan_b), src/util.c (copy_to_fd, copy_file,
append_to_file): Unless the --follow-symlinks option is given, open files with
the O_NOFOLLOW flag to avoid following symlinks.  So far, we were only doing
that consistently for input files.
* src/util.c (create_backup): When creating empty backup files, (re)create them
with O_CREAT | O_EXCL to avoid following symlinks in that case as well.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't crash when RLIMIT_NOFILE is set to RLIM_INFINITY</title>
<updated>2019-06-28T09:20:31+00:00</updated>
<author>
<name>Andreas Gruenbacher</name>
<email>agruen@gnu.org</email>
</author>
<published>2019-06-27T09:10:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/commit/?id=61d7788b83b302207a67b82786f4fd79e3538f30'/>
<id>61d7788b83b302207a67b82786f4fd79e3538f30</id>
<content type='text'>
* src/safe.c (min_cached_fds): Define minimum number of cached dir file
descriptors.
(max_cached_fds): Change type to rlim_t to allow storing RLIM_INFINITY.
(init_dirfd_cache): Set max_cached_fds to RLIM_INFINITY when RLIMIT_NOFILE is
RLIM_INFINITY.  Set the initial hash table size to min_cached_fds, independent
of RLIMIT_NOFILE: patches commonly only affect one or a few files, so a small
hash table will usually suffice; if needed, the hash table will grow.
(insert_cached_dirfd): Don't shrink the cache when max_cached_fds is
RLIM_INFINITY.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* src/safe.c (min_cached_fds): Define minimum number of cached dir file
descriptors.
(max_cached_fds): Change type to rlim_t to allow storing RLIM_INFINITY.
(init_dirfd_cache): Set max_cached_fds to RLIM_INFINITY when RLIMIT_NOFILE is
RLIM_INFINITY.  Set the initial hash table size to min_cached_fds, independent
of RLIMIT_NOFILE: patches commonly only affect one or a few files, so a small
hash table will usually suffice; if needed, the hash table will grow.
(insert_cached_dirfd): Don't shrink the cache when max_cached_fds is
RLIM_INFINITY.
</pre>
</div>
</content>
</entry>
<entry>
<title>Abort when cleaning up fails</title>
<updated>2019-06-27T22:46:06+00:00</updated>
<author>
<name>Andreas Gruenbacher</name>
<email>agruen@gnu.org</email>
</author>
<published>2019-06-27T22:30:25+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/commit/?id=b7b028a77bd855f6f56b17c8837fc1cca77b469d'/>
<id>b7b028a77bd855f6f56b17c8837fc1cca77b469d</id>
<content type='text'>
When a fatal error triggers during cleanup, another attempt will be made to
clean up, which will likely lead to the same fatal error.  So instead, bail out
when that happens.
src/patch.c (cleanup): Bail out when called recursively.
(main): There is no need to call output_files() before cleanup() as cleanup()
already does that.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When a fatal error triggers during cleanup, another attempt will be made to
clean up, which will likely lead to the same fatal error.  So instead, bail out
when that happens.
src/patch.c (cleanup): Bail out when called recursively.
(main): There is no need to call output_files() before cleanup() as cleanup()
already does that.
</pre>
</div>
</content>
</entry>
<entry>
<title>Improve support for memory leak detection</title>
<updated>2019-06-27T09:07:01+00:00</updated>
<author>
<name>Andreas Gruenbacher</name>
<email>agruen@gnu.org</email>
</author>
<published>2019-06-27T09:02:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/commit/?id=2b584aec9e5f2806b1eccadcabe7e901fcfa0b0a'/>
<id>2b584aec9e5f2806b1eccadcabe7e901fcfa0b0a</id>
<content type='text'>
When building with the address sanitizer on, free some more resources before
exiting.  (This is unnecessary when not looking for memory leaks.)
* src/patch.c (init_files_to_delete): Add dispose function for freeing
filenames.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When building with the address sanitizer on, free some more resources before
exiting.  (This is unnecessary when not looking for memory leaks.)
* src/patch.c (init_files_to_delete): Add dispose function for freeing
filenames.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix swapping fake lines in pch_swap</title>
<updated>2018-08-17T14:27:11+00:00</updated>
<author>
<name>Andreas Gruenbacher</name>
<email>agruen@gnu.org</email>
</author>
<published>2018-08-17T11:35:40+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/commit/?id=9c986353e420ead6e706262bf204d6e03322c300'/>
<id>9c986353e420ead6e706262bf204d6e03322c300</id>
<content type='text'>
* src/pch.c (pch_swap): Fix swapping p_bfake and p_efake when there is a
blank line in the middle of a context-diff hunk: that empty line stays
in the middle of the hunk and isn't swapped.

Fixes: https://savannah.gnu.org/bugs/index.php?53133
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* src/pch.c (pch_swap): Fix swapping p_bfake and p_efake when there is a
blank line in the middle of a context-diff hunk: that empty line stays
in the middle of the hunk and isn't swapped.

Fixes: https://savannah.gnu.org/bugs/index.php?53133
</pre>
</div>
</content>
</entry>
<entry>
<title>Make the (debug &amp; 2) output more useful</title>
<updated>2018-08-17T11:13:54+00:00</updated>
<author>
<name>Andreas Gruenbacher</name>
<email>agruen@gnu.org</email>
</author>
<published>2018-08-17T08:31:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/patch.git/commit/?id=ff81775f4eb6ab9a91b75e4031e8216654c0c76a'/>
<id>ff81775f4eb6ab9a91b75e4031e8216654c0c76a</id>
<content type='text'>
* src/pch.c (another_hunk): In the (debug &amp; 2) output, fix how empty
lines that are not part of the patch context are printed.  Also, add
newlines to lines that are missing them to keep the output readable.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* src/pch.c (another_hunk): In the (debug &amp; 2) output, fix how empty
lines that are not part of the patch context are printed.  Also, add
newlines to lines that are missing them to keep the output readable.
</pre>
</div>
</content>
</entry>
</feed>
