chiark / gitweb /
fix cht_get_urandom error handling
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jun 2012 12:25:49 +0000 (13:25 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jun 2012 12:25:49 +0000 (13:25 +0100)
base/hook.c
debian/changelog

index 82d01cfb6fd75d9dc0aa5ac46f021065964c7786..6e4b3a102e4abe26cf48cdb26faad2066dd2d439 100644 (file)
@@ -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) {
index 6c6b614d682baad59cd04648911a84c1bea98c9a..f24075ad551c25a46dc4ce1b07d7bc69c18b3c4a 100644 (file)
@@ -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.