• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 29378720657

14 Jul 2026 11:44PM UTC coverage: 72.936% (-0.004%) from 72.94%
29378720657

push

github

yuwata
sd-dhcp-relay: fix off-by-one when discarding BOOTREQUEST messages by hops count

According to RFC specifications
```
RFC 1542 section 4.1.1 states:
The relay agent MUST silently discard BOOTREQUEST messages whose 'hops'
   field exceeds the value 16."
```

"Exceeds the value 16" means hops > 16, i.e. a message that arrives with
hops == 16 is still valid and must be relayed (after which its hops field
becomes 17). The code used ">= 16", which silently dropped a valid message
that had legitimately traversed exactly 16 relay agents, one hop too early.

This matches the wording of the adjacent comment, which already says
"exceeds the value 16".

2 of 2 new or added lines in 2 files covered. (100.0%)

4253 existing lines in 80 files now uncovered.

345834 of 474164 relevant lines covered (72.94%)

1318659.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.5
/src/basic/gunicode.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
/* gunicode.c - Unicode manipulation functions
3
 *
4
 *  Copyright (C) 1999, 2000 Tom Tromey
5
 *  Copyright © 2000, 2005 Red Hat, Inc.
6
 */
7

8
#include <stdlib.h>
9

10
#include "gunicode.h"
11

12
#define unichar uint32_t
13

14
/**
15
 * g_utf8_prev_char:
16
 * @p: a pointer to a position within a UTF-8 encoded string
17
 *
18
 * Finds the previous UTF-8 character in the string before @p.
19
 *
20
 * @p does not have to be at the beginning of a UTF-8 character. No check
21
 * is made to see if the character found is actually valid other than
22
 * it starts with an appropriate byte. If @p might be the first
23
 * character of the string, you must use g_utf8_find_prev_char() instead.
24
 *
25
 * Return value: a pointer to the found character.
26
 **/
27
char *
UNCOV
28
utf8_prev_char (const char *p)
×
29
{
UNCOV
30
  assert(p);
×
31

UNCOV
32
  for (;;)
×
33
    {
UNCOV
34
      p--;
×
UNCOV
35
      if ((*p & 0xc0) != 0x80)
×
UNCOV
36
        return (char *)p;
×
37
    }
38
}
39

40
struct Interval
41
{
42
  unichar start, end;
43
};
44

45
static int
46
interval_compare (const void *key, const void *elt)
80,878,339✔
47
{
48
  unichar c = (unichar) (long) (key);
80,878,339✔
49
  struct Interval *interval = (struct Interval *)elt;
80,878,339✔
50

51
  if (c < interval->start)
80,878,339✔
52
    return -1;
53
  if (c > interval->end)
36,611✔
54
    return +1;
31,954✔
55

56
  return 0;
57
}
58

59
/*
60
 * NOTE:
61
 *
62
 * The tables for g_unichar_iswide() and g_unichar_iswide_cjk() are
63
 * generated from the Unicode Character Database's file
64
 * extracted/DerivedEastAsianWidth.txt using the gen-iswide-table.py
65
 * in this way:
66
 *
67
 *   ./gen-iswide-table.py < path/to/ucd/extracted/DerivedEastAsianWidth.txt | fmt
68
 *
69
 * Last update for Unicode 6.0.
70
 */
71

72
/**
73
 * g_unichar_iswide:
74
 * @c: a Unicode character
75
 *
76
 * Determines if a character is typically rendered in a double-width
77
 * cell.
78
 *
79
 * Return value: %TRUE if the character is wide
80
 **/
81
bool
82
unichar_iswide (unichar c)
13,482,897✔
83
{
84
  /* See NOTE earlier for how to update this table. */
85
  static const struct Interval wide[] = {
13,482,897✔
86
    {0x1100, 0x115F}, {0x2329, 0x232A}, {0x2E80, 0x2E99}, {0x2E9B, 0x2EF3},
87
    {0x2F00, 0x2FD5}, {0x2FF0, 0x2FFB}, {0x3000, 0x303E}, {0x3041, 0x3096},
88
    {0x3099, 0x30FF}, {0x3105, 0x312D}, {0x3131, 0x318E}, {0x3190, 0x31BA},
89
    {0x31C0, 0x31E3}, {0x31F0, 0x321E}, {0x3220, 0x3247}, {0x3250, 0x32FE},
90
    {0x3300, 0x4DBF}, {0x4E00, 0xA48C}, {0xA490, 0xA4C6}, {0xA960, 0xA97C},
91
    {0xAC00, 0xD7A3}, {0xF900, 0xFAFF}, {0xFE10, 0xFE19}, {0xFE30, 0xFE52},
92
    {0xFE54, 0xFE66}, {0xFE68, 0xFE6B}, {0xFF01, 0xFF60}, {0xFFE0, 0xFFE6},
93
    {0x1B000, 0x1B001}, {0x1F200, 0x1F202}, {0x1F210, 0x1F23A},
94
    {0x1F240, 0x1F248}, {0x1F250, 0x1F251},
95
    {0x1F300, 0x1F567}, /* Miscellaneous Symbols and Pictographs */
96
    {0x20000, 0x2FFFD}, {0x30000, 0x3FFFD},
97
  };
98

99
  if (bsearch ((void *)(uintptr_t)c, wide, ELEMENTSOF(wide), sizeof wide[0],
26,965,794✔
100
               interval_compare))
101
    return true;
4,657✔
102

103
  return false;
104
}
105

106
const char utf8_skip_data[256] = {
107
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
108
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
109
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
110
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
111
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
112
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
113
  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
114
  3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
115
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc