Commit c346f903 authored by Lev Walkin's avatar Lev Walkin

easier fix for sanitization (by @velichkov)

parent ebeb4015
......@@ -791,25 +791,21 @@ INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
#endif /* ASN_DISABLE_PER_SUPPORT */
/*
* This function is only to get rid of Undefined Behavior Sanitizer warning.
*/
static intmax_t CC_ATTR_NO_SANITIZE("shift-base")
asn__safe_integer_convert_helper(const uint8_t *b, const uint8_t *end) {
intmax_t value;
/* Perform the sign initialization */
/* Actually value = -(*b >> 7); gains nothing, yet unreadable! */
if((*b >> 7)) {
value = -1;
static intmax_t
asn__integer_convert(const uint8_t *b, const uint8_t *end) {
uintmax_t value;
/* Perform the sign initialization */
/* Actually value = -(*b >> 7); gains nothing, yet unreadable! */
if((*b >> 7)) {
value = (uintmax_t)(-1);
} else {
value = 0;
}
/* Conversion engine */
for(; b < end; b++) {
value = (value << 8) | *b;
for(; b < end; b++) {
value = (value << 8) | *b;
}
return value;
......@@ -862,7 +858,7 @@ asn_INTEGER2imax(const INTEGER_t *iptr, intmax_t *lptr) {
return 0;
}
*lptr = asn__safe_integer_convert_helper(b, end);
*lptr = asn__integer_convert(b, end);
return 0;
}
......
......@@ -9,18 +9,14 @@
#include <NativeEnumerated.h>
#include <errno.h>
/*
* This function is only to get rid of Undefined Behavior Sanitizer warning.
*/
static intmax_t CC_ATTR_NO_SANITIZE("shift-base")
asn__safe_nativeenumerated_convert_helper(const uint8_t *b,
const uint8_t *end) {
intmax_t value;
static intmax_t
asn__nativeenumerated_convert(const uint8_t *b, const uint8_t *end) {
uintmax_t value;
/* Perform the sign initialization */
/* Actually value = -(*b >> 7); gains nothing, yet unreadable! */
if((*b >> 7)) {
value = -1;
value = (uintmax_t)(-1);
} else {
value = 0;
}
......@@ -77,7 +73,7 @@ NativeEnumerated_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
b++;
bend = b + length;
value = asn__safe_nativeenumerated_convert_helper(b, bend);
value = asn__nativeenumerated_convert(b, bend);
if(value < 0) {
const asn_INTEGER_specifics_t *specs =
(const asn_INTEGER_specifics_t *)td->specifics;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment