Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
aports
aports
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 652
    • Issues 652
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 173
    • Merge Requests 173
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • alpine
  • aportsaports
  • Issues
  • #8028

Closed
Open
Opened Oct 22, 2017 by William Shallum@wshallum
  • Report abuse
  • New issue
Report abuse New issue

Busybox syslogd -Z option broken

The patch 0015-syslogd-adjust-timezone-option.patch should probably set the year in the struct tm to something representable. Not sure if this is 32 bit bug only.

Package Version: busybox 1.26.2-r7, Intel 32 bit.

To reproduce:

# service syslog stop
# syslogd -N -O - -Z

In other terminal:

$ logger -t test test

Expected output: the correct date

Actual output:

Dec 31 23:59:59 vm user.notice test: test

This happens because mktime actually fails with EOVERFLOW (tm_year is initialized to 0 = the year 1900 which is not representable in 32 bit time_t) and returns (time_t)-1.

Simple program to reproduce below:

#include <stdio.h>
#include <time.h>

void doit(const char *ts, struct tm *nowtm) {
    time_t tm;
    if (!strptime(ts, "%b %e %T", nowtm)) {
        fprintf(stderr, "Err strptime\n");
    }
    printf("Year is %d\n", nowtm->tm_year);
    tm = mktime(nowtm);
    if (tm == (time_t)-1) {
        perror("mktime");
    }
    printf("Parsed as: %s\n", ctime(&tm));
}

int main() {
    const char *ts = "Oct 22 02:17:13";
    struct tm origtm = { .tm_isdst = 0 };
    struct tm fixedtm = { .tm_isdst = 0, .tm_year=100 };
    tzset();
    printf("With original:\n");
    doit(ts, &origtm);
    printf("With fixed:\n");
    doit(ts, &fixedtm);
}

(from redmine: issue id 8028, created on 2017-10-22)

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
3
Labels
Aports Normal type:bug
Assign labels
  • View project labels
Reference: alpine/aports#8028