Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pppd: Fix printing 64-bit counters #528

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pppd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ print_link_stats(void)
if (link_stats_print && link_stats_valid) {
int t = (link_connect_time + 5) / 6; /* 1/10ths of minutes */
info("Connect time %d.%d minutes.", t/10, t%10);
info("Sent %u bytes, received %u bytes.",
info("Sent %llu bytes, received %llu bytes.",
link_stats.bytes_out, link_stats.bytes_in);
link_stats_print = 0;
}
Expand Down
28 changes: 26 additions & 2 deletions pppd/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ vslprintf(char *buf, int buflen, const char *fmt, va_list args)
int c, i, n;
int width, prec, fillch;
int base, len, neg, quoted;
long lval = 0;
unsigned long val = 0;
long long lval = 0;
unsigned long long val = 0;
char *str, *buf0;
const char *f;
unsigned char *p;
Expand Down Expand Up @@ -208,6 +208,30 @@ vslprintf(char *buf, int buflen, const char *fmt, va_list args)
case 'l':
c = *fmt++;
switch (c) {
case 'l':
c = *fmt++;
switch (c) {
case 'd':
lval = va_arg(args, long long);
if (lval < 0) {
neg = 1;
val = -lval;
} else
val = lval;
base = 10;
break;
case 'u':
val = va_arg(args, unsigned long long);
base = 10;
break;
default:
OUTCHAR('%');
OUTCHAR('l');
OUTCHAR('l');
--fmt; /* so %llz outputs %llz etc. */
continue;
}
break;
case 'd':
lval = va_arg(args, long);
if (lval < 0) {
Expand Down