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

while add a invalid service in the directory of /etc/chkconfig.d, execute chkconfig will coredump #40

Open
fayeinseu opened this issue May 11, 2020 · 3 comments
Assignees
Labels

Comments

@fayeinseu
Copy link

fayeinseu commented May 11, 2020

steps to reproduce:
1.add a service in /etc/chkconfig as below:

#!/bin/bash
# chkconfig: 8 33 99
echo "test chkconfig --override"
  1. execute command :chkconfig
    then os will produce coredump file.
@fayeinseu fayeinseu changed the title while add a invalid service while add a invalid service in the directory of /etc/chkconfig.d, execute chkconfig will coredump May 11, 2020
@fayeinseu
Copy link
Author

fayeinseu commented May 11, 2020

the bug is produced from code below:

int readServiceInfo(char *name, int type, struct service *service,
                    int honorHide) {...
 asprintf(&filename, RUNLEVELS "/chkconfig.d/%s", name);
    if ((fd = open(filename, O_RDONLY)) >= 0) {
        parseret = parseServiceInfo(fd, name, &serv_overrides, honorHide, 1);  //here
        if (parseret >= 0) {
            if (serv_overrides.name)
                serv.name = serv_overrides.name;
...

and when level >6 , it will return 1 while the service name is random inited.
if (serv.levels == -1) { if (!strcmp(levelbuf, "-")) serv.levels = 0; else serv.levels = parseLevels(levelbuf, 0); } if (serv.levels == -1) { if (serv.desc) free(serv.desc); free(bufstart); return 1; }

@fayeinseu
Copy link
Author

@jamacku

@jamacku
Copy link
Member

jamacku commented May 13, 2020

Thank you, I'll have a look at this bug.

@jamacku jamacku self-assigned this May 13, 2020
@jamacku jamacku added the bug label May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants