-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GSoC IPPServer Functionality #120 #121 #122 #139
base: master
Are you sure you want to change the base?
Changes from 4 commits
f43e6c4
ddb287f
81e6635
1321fe3
9446f88
8aaba39
b86b9a8
69cec5c
abb1c46
9cecef0
25873ac
83b39b3
c976be5
faf04bf
6a1629e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -647,31 +647,37 @@ parse_value(_ipp_file_t *f, /* I - IPP data file */ | |
{ | ||
if(value[0]=='<') /* Input is binary(in form of hex) values*/ | ||
{ | ||
memmove(value, value+1, strlen(value)); /* Eliminate the '<' sign */ | ||
char value_concat[50000]; /* Concatenated string with hexadecimal values without whitespace */ | ||
int starting_line_number = f->linenum; | ||
while(value[strlen(value)-1] != '>') | ||
{ | ||
strcat(value_concat,value); | ||
if (!_ippFileReadToken(f, value, sizeof(value))) | ||
{ | ||
report_error(f, v, user_data, "hexadecimal value not terminated starting line %d of \"%s\".", starting_line_number, f->filename); | ||
return (0); | ||
} | ||
} | ||
value[(strlen(value)-1)]='\0'; /* Eliminate the last '>' sign */ | ||
strcat(value_concat,value); /* Final concatenation for hexadecimal value to be complete*/ | ||
int i; /* Iterating variable*/ | ||
for(i=0;i<strlen(value_concat);i++) /* Sanity Check*/ | ||
{ | ||
if(!(value_concat[i] >= '0' && value_concat[i]<= '9') || (value_concat[i]>='a' && value_concat[i]<='f')) | ||
{ | ||
report_error(f, v, user_data, "Bad hexadecimal value \"%s\" on line %d of \"%s\".", value_concat, starting_line_number, f->filename); | ||
return (0); | ||
} | ||
} | ||
return (ippSetOctetString(ipp, attr, element, value_concat, (int)strlen(value_concat))); | ||
} | ||
unsigned char data[32767], *dataptr = data; /*data: decoded hex, dataptr:iterating pointer */ | ||
char *valptr = value + 1; /*Value iterating pointer*/ | ||
while (1) | ||
{ | ||
while (isxdigit(valptr[0]) && isxdigit(valptr[1])) | ||
{ | ||
char c = valptr[0], d=valptr[1]; | ||
/*decode hex pair into 8 bit string */ | ||
dataptr = (d>='a')?(10+d-'a'):(d-'0') + (c>= 'a') ? ((10+c -'a') << 4) : ((c-'0') <<4); | ||
valptr += 2; | ||
dataptr ++; | ||
if (dataptr >= (data + sizeof(data))) | ||
break; | ||
} | ||
if (*valptr == '>') | ||
break; | ||
else if (*valptr) /*If string is not in pairs, or has a non-hex digit*/ | ||
{ | ||
report_error(f, v, user_data, "Bad hexadecimal value \"%s\" on line %d of \"%s\".", value+1, f->linenum, f->filename); | ||
return (0); | ||
} | ||
if (!_ippFileReadToken(f, value, sizeof(value))) | ||
{ | ||
report_error(f, v, user_data, "Missing value on line %d of \"%s\".", f->linenum, f->filename); | ||
return (0); | ||
} | ||
valptr = value; | ||
} | ||
return (ippSetOctetString(ipp, attr, element, data, (int)strlen(data))); | ||
} | ||
|
||
else | ||
{ | ||
return (ippSetOctetString(ipp, attr, element, value, (int)strlen(value))); /* If a quoted string like "..", pass it on */ | ||
|
@@ -682,19 +688,6 @@ parse_value(_ipp_file_t *f, /* I - IPP data file */ | |
break; | ||
|
||
case IPP_TAG_TEXTLANG : | ||
{ | ||
(*attr)->values[element].string.text = _cupsStrAlloc(value); | ||
if (!_ippFileReadToken(f, value, sizeof(value))) | ||
{ | ||
report_error(f, v, user_data, "No Language Data in line %d of \"%s\".", f->linenum, f->filename); | ||
return (0); | ||
} | ||
memmove(value, value+1, strlen(value)); | ||
value[strlen(value)-1]='\0'; /* Purge parenthesis */ | ||
(*attr)->values[element].string.language = _cupsStrAlloc(value); | ||
|
||
} | ||
break; | ||
case IPP_TAG_NAMELANG : | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the same code for IPP_TAG_NAMELANG and IPP_TAG_TEXTLANG (with the two case statements together feeding into the same code). |
||
(*attr)->values[element].string.text = _cupsStrAlloc(value); | ||
|
@@ -703,6 +696,11 @@ parse_value(_ipp_file_t *f, /* I - IPP data file */ | |
report_error(f, v, user_data, "No Language Data in line %d of \"%s\".", f->linenum, f->filename); | ||
return (0); | ||
} | ||
if (!(value[0] == '(' && value[strlen(value)-1] == ')')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you need to read another token here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi! |
||
{ | ||
report_error(f, v, user_data, "Bad Language Value in line %d of \"%s\".", f->linenum, f->filename); | ||
return (0); | ||
} | ||
memmove(value, value+1, strlen(value)); | ||
value[strlen(value)-1]='\0'; /* Purge parenthesis */ | ||
(*attr)->values[element].string.language = _cupsStrAlloc(value); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need "tolower" here, as "isxdigit" allows upper and lowercase letters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!