Fix type of variable used to store fgetc() result

fgetc() returns an int. Fix process_config_file() to store the result in
an int, so that comparisons against EOF succeed.

Previously, If "char" defaulted to unsigned (which may be true for armhf),
then when fgetc() returned -1, it would be truncated to 255 when stored
in the char, and then zero-filled rather than sign-extended when comparing
against EOF, which would then fail.

See http://code.google.com/p/chromium-os/issues/detail?id=25632.

Reported-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Change-Id: I018e32df9a87b7c6f9fe24d108e091a7b31a50c8
Reviewed-on: http://git-master/r/192151
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Allen Martin <amartin@nvidia.com>
This commit is contained in:
Stephen Warren
2013-01-17 14:41:28 -07:00
parent 0bbfaf91d1
commit acbfad4efb

View File

@@ -702,7 +702,7 @@ void process_config_file(build_image_context *context, u_int8_t simple_parse)
{
char buffer[MAX_BUFFER];
int space = 0;
char current;
int current;
u_int8_t c_eol_comment_start = 0; /* True after first slash */
u_int8_t comment = 0;
u_int8_t string = 0;