Bug 153619 - [patch] csup(1): prevent infinite cycle on empty ",v" files
Summary: [patch] csup(1): prevent infinite cycle on empty ",v" files
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 9.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-02 08:20 UTC by Eygene Ryabinkin
Modified: 2016-12-10 15:39 UTC (History)
0 users

See Also:


Attachments
avoid-infinite-cycle-on-broken-files.diff (1.48 KB, patch)
2011-01-02 08:20 UTC, Eygene Ryabinkin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eygene Ryabinkin freebsd_committer freebsd_triage 2011-01-02 08:20:10 UTC
I had an empty "Makefile,v" and csup choked on it, entering
the infinite cycle and grabbing memory.  The problem is that
the 'ID' was defined as 0 and the built-in YY_NULL that tells
the caller that EOF was found is 0 too.  So, the following
cycle on the empty file will be infinite:
{{{
        /* access {id]*; */
        assert(token == KEYWORD);
        token = rcslex(*sp);
        while (token == ID) {
                id = duptext(sp, NULL);
                rcsfile_addaccess(rf, id);
                free(id);
                token = rcslex(*sp);
        }
}}}

Fix: The following patch fixes the problem for me.  Now csup reports the
file in question as broken and stops.  I will try to work on adding
that file to the list of fixups to enable the full retransfer.
How-To-Repeat: 
Truncate any ",v" file in your full CVS repository that is updated by
csup and watch it choking on that entry, grabbing more and more memory
and being killed at the out-of-swap-space condition.
Comment 1 Baptiste Daroussin freebsd_committer freebsd_triage 2016-12-10 15:39:21 UTC
csup is not part of base anymore