...
| Code Block | ||||
|---|---|---|---|---|
| ||||
unsigned int ui1;
unsigned int ui2;
unsigned int uresult;
/* Initialize ui1 and ui2 */
if (ui2 >= sizeof(unsigned int)*CHAR_BIT) {
/* handleHandle error condition */
} else {
uresult = ui1 << ui2;
}
|
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
unsigned int ui1;
unsigned int ui2;
unsigned int uresult;
/* Initialize ui1 and ui2 */
if (ui2 >= sizeof(unsigned int) * CHAR_BIT) {
/* handleHandle error condition */
}
else {
uresult = ui1 >> ui2;
}
|
...
| [Dowd 2006] | Chapter 6, "C Language Issues" |
| [ISO/IEC 2003] | Section 6.5.7, "Bitwise Shift Operators" |
| [Seacord 2005a2013] | Chapter 5, "IntegersInteger Security" |
| [Viega 2005] | Section 5.2.7, "Integer Overflow" |
...