emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117930: movemail: don't dump core if the current ti


From: Paul Eggert
Subject: [Emacs-diffs] trunk r117930: movemail: don't dump core if the current time is outlandish
Date: Tue, 23 Sep 2014 19:21:57 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117930
revision-id: address@hidden
parent: address@hidden
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Tue 2014-09-23 12:21:54 -0700
message:
  movemail: don't dump core if the current time is outlandish
  
  * movemail.c (popmail): Check for mbx_delimit_begin failure.
  (mbx_delimit_begin): Fail if the current time is so outlandish
  that localtime would fail or asctime would have undefined
  behavior.  Use strftime to avoid asctime undefined behavior.
modified:
  lib-src/ChangeLog              changelog-20091113204419-o5vbwnq5f7feedwu-1608
  lib-src/movemail.c             movemail.c-20091113204419-o5vbwnq5f7feedwu-32
=== modified file 'lib-src/ChangeLog'
--- a/lib-src/ChangeLog 2014-09-01 09:54:12 +0000
+++ b/lib-src/ChangeLog 2014-09-23 19:21:54 +0000
@@ -1,3 +1,11 @@
+2014-09-23  Paul Eggert  <address@hidden>
+
+       movemail: don't dump core if the current time is outlandish
+       * movemail.c (popmail): Check for mbx_delimit_begin failure.
+       (mbx_delimit_begin): Fail if the current time is so outlandish
+       that localtime would fail or asctime would have undefined
+       behavior.  Use strftime to avoid asctime undefined behavior.
+
 2014-09-01  Paul Eggert  <address@hidden>
 
        --enable-silent-rules now suppresses more chatter.

=== modified file 'lib-src/movemail.c'
--- a/lib-src/movemail.c        2014-07-14 19:23:18 +0000
+++ b/lib-src/movemail.c        2014-09-23 19:21:54 +0000
@@ -714,8 +714,8 @@
 
   for (i = start; i * increment <= end * increment; i += increment)
     {
-      mbx_delimit_begin (mbf);
-      if (pop_retr (server, i, mbf) != OK)
+      if (mbx_delimit_begin (mbf) != OK
+         || pop_retr (server, i, mbf) != OK)
        {
          error ("%s", Errmsg, 0);
          close (mbfi);
@@ -832,15 +832,15 @@
 static int
 mbx_delimit_begin (FILE *mbf)
 {
-  time_t now;
-  struct tm *ltime;
-  char fromline[40] = "From movemail ";
-
-  now = time (NULL);
-  ltime = localtime (&now);
-
-  strcat (fromline, asctime (ltime));
-
+  time_t now = time (NULL);
+  struct tm *ltime = localtime (&now);
+  if (!ltime)
+    return NOTOK;
+
+  char fromline[100];
+  if (! strftime (fromline, sizeof fromline,
+                 "From movemail %a %b %e %T %Y\n", ltime))
+    return NOTOK;
   if (fputs (fromline, mbf) == EOF)
     return (NOTOK);
   return (OK);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]