blob: 7eb70449c48dbdbe64f2e9667e8659a83400fdd6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
From dae801527386f94e9d2fabf23c37863d1b599153 Mon Sep 17 00:00:00 2001
From: Roy Eldar <royeldar0@gmail.com>
Date: Thu, 25 May 2023 17:41:58 +0300
Subject: [PATCH] elf: fix handling of negative numbers in dl-printf
_dl_debug_vdprintf is a bare-bones printf implementation; currently
printing a signed integer (using "%d" format specifier) behaves
incorrectly when the number is negative, as it just prints the
corresponding unsigned integer, preceeded by a minus sign.
For example, _dl_printf("%d", -1) would print '-4294967295'.
Signed-off-by: Roy Eldar <royeldar0@gmail.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reference:https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=dae801527386f94e9d2fabf23c37863d1b599153
Conflict:NA
---
elf/dl-misc.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/elf/dl-misc.c b/elf/dl-misc.c
index 4a33737c..bba2e714 100644
--- a/elf/dl-misc.c
+++ b/elf/dl-misc.c
@@ -193,19 +193,25 @@ _dl_debug_vdprintf (int fd, int tag_p, const char *fmt, va_list arg)
if (long_mod)
{
if ((long int) num < 0)
- negative = true;
+ {
+ num = -num;
+ negative = true;
+ }
}
else
{
if ((int) num < 0)
{
- num = (unsigned int) num;
+ num = -(unsigned int) num;
negative = true;
}
}
#else
if ((int) num < 0)
- negative = true;
+ {
+ num = -num;
+ negative = true;
+ }
#endif
}
--
2.33.0
|