From c6f18281927becb769ab2ad2bc198b25f5e660b0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 2 Jun 2012 13:25:49 +0100 Subject: [PATCH] fix cht_get_urandom error handling --- base/hook.c | 11 +++++------ debian/changelog | 6 +++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/base/hook.c b/base/hook.c index 82d01cf..6e4b3a1 100644 --- a/base/hook.c +++ b/base/hook.c @@ -84,7 +84,7 @@ void cht_obj_updatestr_string(Tcl_Obj *o, const char *str) { int cht_get_urandom(Tcl_Interp *ip, Byte *buffer, int l) { static FILE *urandom; - int r, esave; + int r; if (!urandom) { urandom= fopen(URANDOM,"rb"); @@ -93,15 +93,14 @@ int cht_get_urandom(Tcl_Interp *ip, Byte *buffer, int l) { r= fread(buffer,1,l,urandom); if (r==l) return 0; - esave= errno; - fclose(urandom); urandom=0; - if (ferror(urandom)) { - return cht_posixerr(ip,errno,"read " URANDOM); + r = cht_posixerr(ip,errno,"read " URANDOM); } else { assert(feof(urandom)); - return cht_staticerr(ip, URANDOM " gave eof!", 0); + r = cht_staticerr(ip, URANDOM " gave eof!", 0); } + fclose(urandom); urandom=0; + return r; } void cht_prepare__basic(Tcl_Interp *ip) { diff --git a/debian/changelog b/debian/changelog index 6c6b614..f24075a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,8 @@ -chiark-tcl (1.1.1) unstable; urgency=low +chiark-tcl (1.1.1~~iwj) unstable; urgency=low + + Bugfix: + * Handling of errors reading /dev/urandom fixed. (Also, fixes + FTBFS in sid due to warning from recent versions of gcc.) User-visible change: * Mention dgram, tuntap and maskmap in Description. Fix typo. -- 2.30.2