]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hexdump: fixes Heap-buffer-overflow in rewrite_rules
authorWanBingjiang <wanbingjiang@webray.com.cn>
Mon, 2 Feb 2026 06:55:11 +0000 (14:55 +0800)
committerWanBingjiang <wanbingjiang@webray.com.cn>
Mon, 2 Feb 2026 06:55:11 +0000 (14:55 +0800)
text-utils/hexdump-parse.c

index efc39c3b3b41dd259addfaf12e2bfb7b2ca03257..9363b957da204052e18011005cd340bbde72e5c3 100644 (file)
@@ -358,14 +358,15 @@ isint:                            cs[3] = '\0';
                                                FALLTHROUGH;
                                        case 'a':
                                                pr->flags = F_ADDRESS;
-                                               ++p2;
-                                               if (first_letter(p1 + 2, "dox")) {
+                                               if (p1[2] && first_letter(p1 + 2, "dox")) {
+                                                       ++p2;
                                                        cs[0] = 'l';
                                                        cs[1] = 'l';
                                                        cs[2] = p1[2];
                                                        cs[3] = '\0';
                                                } else {
-                                                       p1[3] = '\0';
+                                                       if (p1[2])
+                                                               p1[3] = '\0';
                                                        badconv(p1);
                                                }
                                                break;