From: ianmdlvl Date: Sat, 5 Aug 2006 14:34:08 +0000 (+0000) Subject: @@ -1,3 +1,11 @@ X-Git-Tag: debian_version_4_1_4~1 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=11633c3162005c1ce29fdd88b5db4d08a104d07a @@ -1,3 +1,11 @@ +chiark-utils (4.1.4) unstable; urgency=low + + summer bugfix: + * `buf' is used reentrantely by recurse() and sometimes is the `path' + argument to recurse; cope appropriately. + + -- Ian Jackson Sat, 5 Aug 2006 15:34:03 +0100 + chiark-utils (4.1.3) unstable; urgency=low backup snap remountrocp fixes: --- diff --git a/cprogs/summer.c b/cprogs/summer.c index 887409d..2c4f9df 100644 --- a/cprogs/summer.c +++ b/cprogs/summer.c @@ -287,24 +287,29 @@ static int recurse_compar(const void *av, const void *bv) { return strcmp((*a)->d_name, (*b)->d_name); } -static void recurse(const char *path) { +static void recurse(const char *path_or_buf) { static char *buf; static int buf_allocd; struct dirent **namelist, *const *de; char *subpathp; + const char *path_or_0= path_or_buf==buf ? 0 : path_or_buf; int nentries, pathl, esave, buf_want, i; - pathl= strlen(path); + pathl= strlen(path_or_buf); recurse_maxlen= 2; - nentries= scandir(path, &namelist, recurse_filter, recurse_compar); + nentries= scandir(path_or_buf, &namelist, recurse_filter, recurse_compar); esave= errno; + buf_want= pathl+1+recurse_maxlen+1; if (buf_want > buf_allocd) { buf= mrealloc(buf, buf_want); buf_allocd= buf_want; } - strcpy(buf,path); + /* NOTE that path_or_buf is invalid after this point because + * it might have been realloc'd ! */ + if (path_or_0) strcpy(buf,path_or_0); + buf[pathl]= '/'; subpathp= buf+pathl+1; if (nentries < 0) { @@ -313,6 +318,9 @@ static void recurse(const char *path) { return; } for (i=0, de=namelist; id_name); strcpy(subpathp, (*de)->d_name); node(buf); free(*de); diff --git a/debian/changelog b/debian/changelog index e62b38e..9ef478a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +chiark-utils (4.1.4) unstable; urgency=low + + summer bugfix: + * `buf' is used reentrantely by recurse() and sometimes is the `path' + argument to recurse; cope appropriately. + + -- Ian Jackson Sat, 5 Aug 2006 15:34:03 +0100 + chiark-utils (4.1.3) unstable; urgency=low backup snap remountrocp fixes: