s4:smbd/pidfile.c - fix "asprintf" calls
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 27 May 2010 15:37:15 +0000 (17:37 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Fri, 28 May 2010 08:04:47 +0000 (10:04 +0200)
source4/smbd/pidfile.c

index da3f363ff9ba6a688ecbbdd71ecc094d08c85a24..de93a0390ce10d066d122324785c0843e241b95d 100644 (file)
@@ -38,7 +38,9 @@ pid_t pidfile_pid(const char *piddir, const char *name)
        pid_t ret;
        char *pidFile;
 
-       asprintf(&pidFile, "%s/%s.pid", piddir, name);
+       if (asprintf(&pidFile, "%s/%s.pid", piddir, name) < 0) {
+               return 0;
+       }
 
        fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
 
@@ -85,7 +87,10 @@ void pidfile_create(const char *piddir, const char *name)
        char *pidFile;
        pid_t pid;
 
-       asprintf(&pidFile, "%s/%s.pid", piddir, name);
+       if (asprintf(&pidFile, "%s/%s.pid", piddir, name) < 0) {
+               DEBUG(0,("ERROR: Out of memory\n"));
+               exit(1);
+       }
 
        pid = pidfile_pid(piddir, name);
        if (pid != 0) {