From 7c7a09421a412a8613c1ac4a25dcce3117910687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Olav=20Sel=C3=A5sdal?= Date: Thu, 17 Jan 2013 16:30:30 +0100 Subject: [PATCH] Fix bcd stack smash --- src/ucore_bcd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ucore_bcd.c b/src/ucore_bcd.c index 9a202d9..3dd978c 100644 --- a/src/ucore_bcd.c +++ b/src/ucore_bcd.c @@ -16,14 +16,14 @@ uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler) continue; } - *bcdp |= (*ascii - '0') << shift; - if (shift) { + *bcdp |= (*ascii - '0') << 4; bcdp++; - *bcdp = 0; + } else { + *bcdp = (*ascii - '0'); } - shift = 4 - shift; + shift = !shift; } if (shift) {