Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

[dev.icinga.com #386] Minor cleanups to ./cgi/cgiutils.c #175

Closed
icinga-migration opened this issue Apr 29, 2010 · 2 comments
Closed

[dev.icinga.com #386] Minor cleanups to ./cgi/cgiutils.c #175

icinga-migration opened this issue Apr 29, 2010 · 2 comments

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/386

Created by snakebyte on 2010-04-29 14:59:23 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2010-05-05 14:15:07 +00:00)
Target Version: 1.0.2
Last Update: 2010-05-05 14:15:07 +00:00 (in Redmine)


hi,

there are two unused variables (found and statbuf) as well
as a memory leak (daemon_name is only used once, never freed)
and a descriptor leak (fp never gets closed)

Regards, Eric

--- icinga-core/cgi/cgiutils.c.orig 2010-04-29 16:53:46.000000000 +0200

**+ icinga-core/cgi/cgiutils.c 2010-04-29 16:56:39.000000000 +0200
@ -2291,9 +2291,7 @ int check_daemon_running(void) {
char *proc_file=NULL;
char *input = NULL;
char *val = NULL;

  • char *daemon_name = NULL;
  • struct stat statbuf;
  • int pid, testpid, found;
  • int pid, testpid;
    char input_buffer[CHARLEN];
    mmapfile *fk;
    FILE *fp;
    @ -2306,9 +2304,7 @ int check_daemon_running(void) {
    if((fk=mmap_fopen(lock_file))==NULL) {

/* no lock file found try program name instead */

  • asprintf(&daemon_name,"%s",PROGRAM_NAME_LC);
  • if(asprintf(&proc_file,"/bin/ps -o pid -C %s",daemon_name)-1) {
  •            if(asprintf(&proc\_file,"/bin/ps -o pid -C %s",PROGRAM\_NAME\_LC)-1) {
    

free(proc_file);
return ERROR;
}
@ -2321,13 +2317,14 @ int check_daemon_running(void) {
fgets(input_buffer,CHARLEN-1,fp);
fgets(input_buffer,CHARLEN-1,fp);

  • pclose(fp);
  • free(proc_file);

/* check if entry found */
if (sscanf(input_buffer,"%d",&testpid)!=1) {

  • free(proc_file);
    return ERROR;
    } else {
    /* daemon is running */
  • free(proc_file);
    return OK;
    }
    }

Attachments

Changesets

2010-05-05 14:10:25 +00:00 by mfriedrich b8de14a

minor cleanups to cgiutils.c (Eric Sesterhenn)

fixes #386

2010-05-05 14:12:20 +00:00 by mfriedrich ee0ab2d

minor cleanups to cgiutils.c (Eric Sesterhenn)

fixes #386

Relations:

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2010-05-05 14:14:42 +00:00

  • Assigned to set to mfriedrich
  • Target Version set to 1.0.2

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2010-05-05 14:15:07 +00:00

  • Status changed from New to Resolved
  • Done % changed from 0 to 100

Applied in changeset commit:"ee0ab2d479f822959dc02daf49eef3c158c210a0".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant