Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Issue 5025003: The right implementation of CGPT label conversion between UTF8 and UTF16. (Closed)

Created:
10 years, 1 month ago by Louis
Modified:
9 years, 4 months ago
CC:
chromium-os-reviews_chromium.org, Randall Spangler, gauravsh, Luigi Semenzato, Bill Richardson
Visibility:
Public.

Description

The right implementation of CGPT label conversion between UTF8 and UTF16. For security quick fix, the original UTF8/UTF16 conversion only supports ASCII area. This CL extends the library to support multiple code units conversion between UTF8 and UTF16. The UTF8/UTF16 encoded byte(s) would be decoded to code point first, then be encoded to UTF16/UTF8 correspondingly. Bill, please kindly review the UTF8/UTF16 conversion. Peter, please kindly comment if any security concern. Thanks. Change-Id: I99c558ff27556e0b8635ba2b8d9925d042e75cb2 BUG=chromium-os:7542 TEST=RUNTESTS=1 emerge-x86-generic vboot_reference Manually tested the following commands (intentionally mix Chinese and ASCII): export C=.../cgpt export D=/tmp/hda $C add $D -i 1 -l 批P踢T踢T許C夕C餐 $C find $D -l 批P踢T踢T許C夕C餐 $C show $D $C add $D -i 1 -l 批P踢T踢T許C夕C餐 $C find $D -l 批P踢T踢T許C夕C餐 $C add $D -i 1 -l abc012 $C add $D -i 1 -l 是否看過坊間常見的許茹芸淚海慶功宴吃蓋飯第四集 $C add $D -i 1 -l 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ # ok and truncated $C add $D -i 1 -l `printf "\xf4\x91\x81\x81"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf4\x8f\xbf\xbf"` $C add $D -i 1 -l `printf "\xf4\x8f\x44\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf4\x8f\xbf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\xbf\xbf\xbf"` $C add $D -i 1 -l `printf "\xf0\xbf\xbf\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x84\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x90\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x88\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xed\x80\x80"` $C add $D -i 1 -l `printf "\xed\xa0\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\xbf\xbf"` $C add $D -i 1 -l `printf "\xe0\xbf\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\x90\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\xbf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xd0\x80"` $C add $D -i 1 -l `printf "\xd0\x11"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xd0"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xc0\xaf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\x80"` # (EXPECT: failed) Committed: http://chrome-svn/viewvc/chromeos?view=rev&revision=6965cbf

Patch Set 1 #

Total comments: 16

Patch Set 2 : Fixed per code review opinion. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+199 lines, -31 lines) Patch
M cgpt/cgpt.h View 1 1 chunk +13 lines, -5 lines 0 comments Download
M cgpt/cgpt_common.c View 1 1 chunk +175 lines, -22 lines 0 comments Download
M cgpt/cmd_add.c View 1 1 chunk +5 lines, -2 lines 0 comments Download
M cgpt/cmd_find.c View 1 1 chunk +6 lines, -2 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
Louis
10 years, 1 month ago (2010-11-16 11:30:32 UTC) #1
Louis
re-send for typo.
10 years, 1 month ago (2010-11-16 11:34:48 UTC) #2
Bill Richardson
Found some problems. http://codereview.chromium.org/5025003/diff/1/cgpt/cgpt_common.c File cgpt/cgpt_common.c (right): http://codereview.chromium.org/5025003/diff/1/cgpt/cgpt_common.c#newcode353 cgpt/cgpt_common.c:353: * twice the number of UTF16 ...
10 years, 1 month ago (2010-11-17 17:26:39 UTC) #3
Bill Richardson
one more nit. http://codereview.chromium.org/5025003/diff/1/cgpt/cmd_add.c File cgpt/cmd_add.c (right): http://codereview.chromium.org/5025003/diff/1/cgpt/cmd_add.c#newcode249 cgpt/cmd_add.c:249: goto bad; We should print an ...
10 years, 1 month ago (2010-11-17 17:41:49 UTC) #4
Louis
10 years, 1 month ago (2010-11-18 05:30:19 UTC) #5
Louis
Bill, thanks for your kind review. I've changed some code according to your suggestions. Please ...
10 years, 1 month ago (2010-11-18 05:35:21 UTC) #6
Bill Richardson
Looks great. Thanks, Louis. LGTM.
10 years, 1 month ago (2010-11-18 19:36:56 UTC) #7
sosa
I had to revert this. This change broke the tree. On Thu, Nov 18, 2010 ...
10 years, 1 month ago (2010-11-19 14:00:36 UTC) #8
Bill Richardson
Oops: vboot_reference-1.0-r144: cc1: warnings being treated as errors vboot_reference-1.0-r144: cgpt_common.c: In function 'UTF16ToUTF8': vboot_reference-1.0-r144: cgpt_common.c:373: ...
10 years, 1 month ago (2010-11-19 15:58:09 UTC) #9
Louis
Hm... my carelessness. The state machine should always initialize the variable. Will fix it soon. ...
10 years, 1 month ago (2010-11-22 01:49:38 UTC) #10
Louis
10 years, 1 month ago (2010-11-22 02:21:06 UTC) #11

Powered by Google App Engine
This is Rietveld 408576698