Bug#571754: strftime("%c") crashes in (some) locations
Klaus Ethgen a écrit : > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA512 > > Hello Bart, > > Am Mo den 1. Mär 2010 um 15:13 schrieb Bart Martens: >> This is the example in "man strptime": > [...] >> As we can see, there's no "memset" initializing the entire tm structure. >> It would be nice to have a "memset" added in this example, to illustrate >> the text "that tm should be initialized before the call". > > I can support this. Would be very helpful. It should be easy to do the > change in the man page only but a note to the upstream could be useful > as well to share that to other distributions too. > > I would also note in the description of the tm struct that they could be > other members not listen in the man page. Otherwise some could see it a > way to initialize all listed members explicit. > the best for that would be to fill a bug against manpages-dev which contains this manpage. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4b8bf352.6030...@aurel32.net
Bug#571754: strftime("%c") crashes in (some) locations
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hello Bart, Am Mo den 1. Mär 2010 um 15:13 schrieb Bart Martens: > This is the example in "man strptime": [...] > As we can see, there's no "memset" initializing the entire tm structure. > It would be nice to have a "memset" added in this example, to illustrate > the text "that tm should be initialized before the call". I can support this. Would be very helpful. It should be easy to do the change in the man page only but a note to the upstream could be useful as well to share that to other distributions too. I would also note in the description of the tm struct that they could be other members not listen in the man page. Otherwise some could see it a way to initialize all listed members explicit. Regards Klaus - -- Klaus Ethgenhttp://www.ethgen.de/ pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEVAwUBS4vo65+OKpjRpO3lAQr+Bwf/SLZhXDe9RuHZya73WDRkxPBHAXSE2YEU AEKgO/P4buyHNvh7HSCIFHqgXh/tN3JUMW2CXnTdsB9A/e5ZFLAfltewmIFf8w8g wLHIobaQU8LT4pluUxOwFh7OiDafAeJ2y5BQEcAxre/C9LDI/AJytiSj6W5+XH/w OBZjAeuFsa0U3Fx6uXhpPEwK494eblJwcpejhhIpWTDWUvOZ+EP298yS/jNMEQlG xFTk4Nvjkj1v5cNEYZXhfMfsdf3mC/dvTyhg+h/DaQ1zLAhAHgQeCHpSSf4JtA+y BKZiIW/i+xeirdIJTRBxsoDrrTrrkM2CTBEzCmMThQX6dnurQQKX2w== =s4/0 -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100301161851.ga18...@ikki.ethgen.de
Bug#571754: strftime("%c") crashes in (some) locations
Hello Aurelien, Hello Klaus, This is the example in "man strptime": #define _XOPEN_SOURCE #include #include #include int main(void) { struct tm tm; char buf[255]; strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm); strftime(buf, sizeof(buf), "%d %b %Y %H:%M", &tm); puts(buf); exit(EXIT_SUCCESS); } As we can see, there's no "memset" initializing the entire tm structure. It would be nice to have a "memset" added in this example, to illustrate the text "that tm should be initialized before the call". Regards, Bart Martens -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/1267452832.3684.28.ca...@tatty.hg67.intranet
Bug#571754: strftime("%c") crashes in (some) locations
On Sun, Feb 28, 2010 at 02:28:08PM +0100, Aurelien Jarno wrote: > reopen 571754 > thanks > > On Sun, Feb 28, 2010 at 01:21:11PM +0100, Klaus Ethgen wrote: > > But however, lets modify the program slightly to be constructive: > > --- > > #define _XOPEN_SOURCE > > #include > > #include > > #include > > > > int main(int argc, char **argv) > > { > >char time[255]; > >struct tm tm; > > > >setlocale(LC_ALL, "de_DE"); > >strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm); > > > >strftime(time, sizeof(time), "%c", &tm); > >fprintf(stdout, "%s\n", time); > > } // int main(int argc, char **argv... > > --- > > > > Now it should be ok for you too. (See, it is nearly the same than the > > example in the man page!) > > > > Thanks for this new example, I am now able to reproducible the problem, > I have therefore reopened the bug. > I am afraid the bug is again in your code. strftime() crashes because tm.tm_zone point to a non allocated memory zone. Initializing the struct tm with strptime() is not enough as it only update the structure, and it doesn't update this field. The correct way to do it is to add the following line before the call to strptime(): memset(&tm, 0, sizeof(tm)); Then it doesn't crash anymore. Ok to close the bug? -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100228145136.ga32...@volta.aurel32.net
Bug#571754: strftime("%c") crashes in (some) locations
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Am So den 28. Feb 2010 um 14:24 schrieb Aurelien Jarno: > Yes, and I explained you why your code is wrong. A part, which was not related to the bug itself. > > Please do not try to find typos in places were no bug is and check the > > real bug source (strftime and NOT localtime, which was added by me only > > for having a tm struct to test with). > > This is actually what's causing the bug. No. I did say that the bug is in strftime and this part was not reached in the example code. So well, I admit that I did the example wrong by fastly putting some code around. But the bug is in the localization of strftime and that was what I told in the description of the bug. > > So please be not that ignorant. I have a pretty high opinion of debian. > > Please don't destroy that! > Please don't be stupid. Sorry, but I have to return the compliment. But lets stop going to the personal level and stay on the objective level. Now you seems to have a code snipplet to reproduce the bug. So looking forward to get this solved. Regards Klaus - -- Klaus Ethgenhttp://www.ethgen.de/ pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEVAwUBS4pyhp+OKpjRpO3lAQrCxgf/Zl/1q23AxMvOqEpJ8iUJyH8dD0Bse26V X3/NtSY1jfGJIY1I8GwBXMktsKG0lZke/D/LH6nGoFRrEHGlUrZCWOHWV4hysnr7 wpSth45d+sZlH8x7Ay0fJkSA+yd+emxjqKYWXDCpJElF/yrDT3c3Fluc27CNQlOv 4nqwQ7rCLNxPVBek7HquuIUSf2xNo4r5Nro8Mf98haXdLda4SMIPVVnGVO8tJ1Hc ln9UIJ4NB8hqYoO2Sud2lY82GfWnIv0OTMDvyRaqpmgi9dTunFY4WAaqJhP1zFJZ MYK/n2aWMiAK9DlkkQYHysueidP4vnGs3JZT33tXNIHIUKU1NCq2yg== =lxCA -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100228134127.gc23...@ikki.ethgen.de
Bug#571754: strftime("%c") crashes in (some) locations
Klaus Ethgen, le Sun 28 Feb 2010 14:41:27 +0100, a écrit : > Am So den 28. Feb 2010 um 14:24 schrieb Aurelien Jarno: > > Yes, and I explained you why your code is wrong. > > A part, which was not related to the bug itself. The bug was not explained at all except the output of a buggy program :) Never forget, in a bug report, to tell what you get, and what you expect to get. None of the two are always obvious (especially when it comes to i18n). Samuel -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100228134744.gj11...@const.famille.thibault.fr
Processed: Re: Bug#571754: strftime("%c") crashes in (some) locations
Processing commands for cont...@bugs.debian.org: > reopen 571754 Bug #571754 {Done: Aurelien Jarno } [libc6] strftime("%c") crashes in (some) locations > thanks Stopping processing here. Please contact me if you need assistance. Debian bug tracking system administrator (administrator, Debian Bugs database) -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/handler.s.c.12673636901036.transcr...@bugs.debian.org
Bug#571754: strftime("%c") crashes in (some) locations
reopen 571754 thanks On Sun, Feb 28, 2010 at 01:21:11PM +0100, Klaus Ethgen wrote: > But however, lets modify the program slightly to be constructive: > --- > #define _XOPEN_SOURCE > #include > #include > #include > > int main(int argc, char **argv) > { >char time[255]; >struct tm tm; > >setlocale(LC_ALL, "de_DE"); >strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm); > >strftime(time, sizeof(time), "%c", &tm); >fprintf(stdout, "%s\n", time); > } // int main(int argc, char **argv... > --- > > Now it should be ok for you too. (See, it is nearly the same than the > example in the man page!) > Thanks for this new example, I am now able to reproducible the problem, I have therefore reopened the bug. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100228132808.gi10...@hall.aurel32.net
Bug#571754: strftime("%c") crashes in (some) locations
On Sun, Feb 28, 2010 at 01:03:12PM +0100, Klaus Ethgen wrote: > Ah, and why is that bug closed? Did you ever try to compile the test > program? Did you ever try to reproduce the bug? Did you??? Yes, and I explained you why your code is wrong. Please provide a real example and I'll reopen the bug. > Please do not try to find typos in places were no bug is and check the > real bug source (strftime and NOT localtime, which was added by me only > for having a tm struct to test with). This is actually what's causing the bug. > So please be not that ignorant. I have a pretty high opinion of debian. > Please don't destroy that! > Please don't be stupid. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100228132454.gh10...@hall.aurel32.net
Bug#571754: strftime("%c") crashes in (some) locations
On Sun, Feb 28, 2010 at 12:58:47PM +0100, Klaus Ethgen wrote: > Hi, > > Am So den 28. Feb 2010 um 10:39 schrieb Aurelien Jarno: > > >setlocale(LC_ALL, "de_DE"); > > >tm = localtime(NULL); > > > > This is wrong. localtime() doesn't accept a NULL pointer. You should > > call time(NULL), and pass the result to localtime(). > > Might be but this isn't the line where it crashes. Also it work's very > well filling the tm struct. > > Note that the crash happens in the next line: > > >strftime(time, sizeof(time), "%c", tm); Because tm is NULL. > but only if the locale is set. This test program is only to demonstrate > the error in strftime, in the original program I get the value for tm > from other places (strptime). > > But however, when rewriting the line to "tm = localtime(time(NULL));" I > get a compile error as there is no such function called time. Maybe > there is something really wrong with the eglibc? > Because you have overrided the time() function with your time variable. This is a bug in *your* code not in eglibc. Here is the fixed version of your code, and it works perfectly. #include #include #include int main(int argc, char **argv) { char strtime[255]; time_t t; struct tm *tm; int ret; setlocale(LC_ALL, "de_DE"); t = time(NULL); tm = localtime(&t); ret = strftime(strtime, sizeof(strtime), "%c", tm); fprintf(stdout, "%s\n", strtime); } // int main(int argc, char **argv... -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100228132351.gg10...@hall.aurel32.net
Bug#571754: strftime("%c") crashes in (some) locations
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 But however, lets modify the program slightly to be constructive: - --- #define _XOPEN_SOURCE #include #include #include int main(int argc, char **argv) { char time[255]; struct tm tm; setlocale(LC_ALL, "de_DE"); strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm); strftime(time, sizeof(time), "%c", &tm); fprintf(stdout, "%s\n", time); } // int main(int argc, char **argv... - --- Now it should be ok for you too. (See, it is nearly the same than the example in the man page!) Regards Klaus - -- Klaus Ethgenhttp://www.ethgen.de/ pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEVAwUBS4pft5+OKpjRpO3lAQp/dAgAojs8hOlHzt/H5Y8NTnBGcW5Akk5XRYtK BI/28G3qcbqR0523/mE3VXfkXDBaa2cWYt911a7CNGkb/J57T4fHwo1due2JT/c+ Y5EwjVXzdAtvISmAi/o/4FbrssWRvWReJgWYxwlFGUKiUB5OPJAsquXsiwJRUL8b EpqMom5fKmmCzKaqe1Jj6JWb86tecTKfus4dVubSNQlmFHWDngGa9rOYX/oYhWPI u+ulSGVhKPuE6piORaTFb/3LtyICHDY5LVm+iZAIK7Fccp6/lAisSpkoeePESjkh TjTs/NhA9PiasAm2/xZR5L9+2tB7DzVI4WQ9h87hwiqxvSAVPXq31g== =yQmo -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100228122111.gd4...@ikki.ethgen.de
Bug#571754: strftime("%c") crashes in (some) locations
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Ah, and why is that bug closed? Did you ever try to compile the test program? Did you ever try to reproduce the bug? Did you??? Please do not try to find typos in places were no bug is and check the real bug source (strftime and NOT localtime, which was added by me only for having a tm struct to test with). So please be not that ignorant. I have a pretty high opinion of debian. Please don't destroy that! Regards Klaus - -- Klaus Ethgenhttp://www.ethgen.de/ pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEVAwUBS4pbgJ+OKpjRpO3lAQrTDggAkcFiF8CNjjPxRAtTCd7I7ulfA/bSiPNd yesZ/Ak0nDFHZQM7i3A7GH7VPAEuSpkNIz7Eu9R7EuW2TgMZ1fuXvMBlgdhXE+1c IjLR0rw4T/4vwwc6iiVNxlddxjF/tUJGGILVRIaYyb3pqCRuyLX9QnPn02ncaNOd M5PTipyDgIpTgcjfEwaEAWq5bJQTipcprzOJFO18DgGDu9ZsIxT+z3/jBzwV7eKy t0CZABfFGhNdojHzz8BCKYnvAj5Du8QqFyc3UidOIeBgy31uzrTqwI33L2CEs2rV wzZi+gLcQ3YYQlRfQ+jjewm+Cp8ymvwK3VwvS4XXw+2pFkKayO1/yg== =mOXf -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100228120312.gc4...@ikki.ethgen.de
Bug#571754: strftime("%c") crashes in (some) locations
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi, Am So den 28. Feb 2010 um 10:39 schrieb Aurelien Jarno: > >setlocale(LC_ALL, "de_DE"); > >tm = localtime(NULL); > > This is wrong. localtime() doesn't accept a NULL pointer. You should > call time(NULL), and pass the result to localtime(). Might be but this isn't the line where it crashes. Also it work's very well filling the tm struct. Note that the crash happens in the next line: > >strftime(time, sizeof(time), "%c", tm); but only if the locale is set. This test program is only to demonstrate the error in strftime, in the original program I get the value for tm from other places (strptime). But however, when rewriting the line to "tm = localtime(time(NULL));" I get a compile error as there is no such function called time. Maybe there is something really wrong with the eglibc? Gruß Klaus - -- Klaus Ethgenhttp://www.ethgen.de/ pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEVAwUBS4pad5+OKpjRpO3lAQrQfwf/YBQtEC/MtrOPgkVyfvX4/hiJbzMhovX1 oAnU5hf0SqwOAhtfb9wyaORlU1uK9yC/zuYBo8APoOIgXAh9kPylN2qsCo9Mn4QF ftczEb8n6UrmUoi5f4bj1/TFi1gXmC/vKgZpSHu8o9Dl0h+xQEBVtw8yreKCpfhQ nrxkcTjKwJ2/WxywlHtrAGkbYZq+laodG0NegWIQBUJv4ZO8CbwpXsb4vHkoKbbJ ORqCkgE2G2KbLmjHExjw6LDril4XWGNOpNYTym4WsYkdYeEDCW84cS6riiOwtiPe GVRhfSzErLUU8m6TLU5wG+4NWV2iZs98+iQGLU4xeVe0Xc8hRgjGhA== =+YYx -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100228115847.gb4...@ikki.ethgen.de
Bug#571754: strftime("%c") crashes in (some) locations
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Package: libc6 Version: 2.10.2-6 Severity: normal Tags: l10n To see the bug, please compile and run the following small program: - --- #include #include #include int main(int argc, char **argv) { char time[255]; struct tm *tm; setlocale(LC_ALL, "de_DE"); tm = localtime(NULL); strftime(time, sizeof(time), "%c", tm); fprintf(stdout, "%s\n", time); } // int main(int argc, char **argv... - --- The problem only happens with locale set (to de_DE, no other tested). And only %c is broken. - From the man page: "%c The preferred date and time representation for the current locale." - -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (800, 'unstable'), (700, 'stable'), (600, 'oldstable'), (60, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.32.9 Locale: LANG=de_DE, LC_CTYPE=de_DE (charmap=ISO-8859-1) (ignored: LC_ALL set to de_DE) Shell: /bin/sh linked to /bin/dash Versions of packages libc6 depends on: ii libc-bin 2.10.2-6 Embedded GNU C Library: Binaries ii libgcc1 1:4.4.3-3 GCC support library Versions of packages libc6 recommends: ii libc6-i6862.10.2-6 GNU C Library: Shared libraries [i Versions of packages libc6 suggests: ii debconf [debconf-2.0] 1.5.28 Debian configuration management sy pn glibc-doc (no description available) ii locales 2.10.2-6 Embedded GNU C Library: National L - -- debconf information: * glibc/upgrade: true * glibc/disable-screensaver: glibc/restart-failed: * glibc/restart-services: exim4 cups cron atd - -- Klaus Ethgenhttp://www.ethgen.de/ pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEVAwUBS4lyWp+OKpjRpO3lAQqGmAf8DIWQFSX54bN30XGnuhmN84YazJnNibP8 FWny1RB8nt0+zmgeN+sNX38ioCcWm1+NMpnY8QolUlncbXLyzKO6jIEUW2UC2iMq jZofZ0ijgshS0+1rITt0rMaobW1It2ijTf/O5t8pJypdmB98Cfrh3QblB1nJD6lX 7t1/mvad7oYgWV9aIZeqTo3xi82DEmoHAo+FERhr5BngzhwvUR4spg8/LxrJcfED B3Dtai8AJI5qyIwLHtdeZ/PJLUvW8v0d9vDBVRv8u4A6hmY6ULIg9esnDl1hqiJg vSzlAGS4ohW67ktAcQHxrY5nquU1KE0LuLL9Q2bwo5lKdgcOKPdS8Q== =Ku+2 -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100227192826.ga16...@ikki.ethgen.de