FreeBSD Bugzilla – Attachment 129434 Details for
Bug 173421
[libc] [patch] strptime() accepts formats that should be rejected
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.txt
file.txt (text/plain), 3.05 KB, created by
Fabian Keil
on 2012-11-06 14:30:00 UTC
(
hide
)
Description:
file.txt
Filename:
MIME Type:
Creator:
Fabian Keil
Created:
2012-11-06 14:30:00 UTC
Size:
3.05 KB
patch
obsolete
>From 6c81c0d84f333075569e84ef9008760bd4689e19 Mon Sep 17 00:00:00 2001 >From: Fabian Keil <fk@fabiankeil.de> >Date: Thu, 18 Oct 2012 18:23:00 +0200 >Subject: [PATCH 1/2] Fix hour parsing with %H (or break it differently?) > >If two digits were followed by a space in buf, %H would parse >the two digits and move the format pointer to the end, thus >reporting a completely successful parse operation without >looking at any additional format specifiers. > >This would let the format "%a, %d-%b-%y %H:%M:%S" match >"Thursday, 18-Oct-2012 00:11:22", even though the parsing should >fail after %H matched the 12 (because %y only matches the 20). > >--- > lib/libc/stdtime/strptime.c | 5 ----- > 1 file changed, 5 deletions(-) > >diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c >index a4ea3fd..3117d3b 100644 >--- a/lib/libc/stdtime/strptime.c >+++ b/lib/libc/stdtime/strptime.c >@@ -285,11 +285,6 @@ label: > > tm->tm_hour = i; > >- if (*buf != 0 && >- isspace_l((unsigned char)*buf, locale)) >- while (*ptr != 0 && >- !isspace_l((unsigned char)*ptr, locale)) >- ptr++; > break; > > case 'p': >-- >1.7.12.4 > > >From 7b008a9c6555976d5531b45bc72999c27be7e33e Mon Sep 17 00:00:00 2001 >From: Fabian Keil <fk@fabiankeil.de> >Date: Fri, 26 Oct 2012 11:45:02 +0200 >Subject: [PATCH 2/2] strptime: Apply the previous fix to the rest of the > format specifiers > >Not thoroughly tested. >--- > lib/libc/stdtime/strptime.c | 30 ------------------------------ > 1 file changed, 30 deletions(-) > >diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c >index 3117d3b..7a03c96 100644 >--- a/lib/libc/stdtime/strptime.c >+++ b/lib/libc/stdtime/strptime.c >@@ -248,11 +248,6 @@ label: > tm->tm_sec = i; > } > >- if (*buf != 0 && >- isspace_l((unsigned char)*buf, locale)) >- while (*ptr != 0 && >- !isspace_l((unsigned char)*ptr, locale)) >- ptr++; > break; > > case 'H': >@@ -354,11 +349,6 @@ label: > if (i > 53) > return 0; > >- if (*buf != 0 && >- isspace_l((unsigned char)*buf, locale)) >- while (*ptr != 0 && >- !isspace_l((unsigned char)*ptr, locale)) >- ptr++; > break; > > case 'w': >@@ -371,11 +361,6 @@ label: > > tm->tm_wday = i; > >- if (*buf != 0 && >- isspace_l((unsigned char)*buf, locale)) >- while (*ptr != 0 && >- !isspace_l((unsigned char)*ptr, locale)) >- ptr++; > break; > > case 'd': >@@ -403,11 +388,6 @@ label: > > tm->tm_mday = i; > >- if (*buf != 0 && >- isspace_l((unsigned char)*buf, locale)) >- while (*ptr != 0 && >- !isspace_l((unsigned char)*ptr, locale)) >- ptr++; > break; > > case 'B': >@@ -464,11 +444,6 @@ label: > > tm->tm_mon = i - 1; > >- if (*buf != 0 && >- isspace_l((unsigned char)*buf, locale)) >- while (*ptr != 0 && >- !isspace_l((unsigned char)*ptr, locale)) >- ptr++; > break; > > case 's': >@@ -517,11 +492,6 @@ label: > > tm->tm_year = i; > >- if (*buf != 0 && >- isspace_l((unsigned char)*buf, locale)) >- while (*ptr != 0 && >- !isspace_l((unsigned char)*ptr, locale)) >- ptr++; > break; > > case 'Z': >-- >1.7.12.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 173421
: 129434