Skip to content
This repository was archived by the owner on Oct 23, 2021. It is now read-only.

Commit 4887a7a

Browse files
committed
Fix sudodevd work unexpected when profile is generated
1 parent ff21d04 commit 4887a7a

File tree

6 files changed

+18
-105
lines changed

6 files changed

+18
-105
lines changed

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v0.24 2015-12-20
2+
* Bug fixed
3+
14
v0.23 2015-11-11
25
* A slight performance boost
36
* Colorize output

src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ add_executable (
22
sudodevd
33
sudodevd.c
44
chomp.c
5-
color.c
65
daemonize.c
76
devs.c
87
find.c
@@ -19,7 +18,6 @@ add_executable (
1918
sudodev
2019
sudodev.c
2120
chomp.c
22-
color.c
2321
devs.c
2422
find.c
2523
profile.c

src/color.c

Lines changed: 0 additions & 97 deletions
This file was deleted.

src/color.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifndef __COLOR_H__
2020
#define __COLOR_H__
2121

22-
#define MAX_COLOR_STR_LEN (1<<3)
22+
#define MAX_COLOR_STR_LEN (1 << 3)
2323

2424
/* Make color string */
2525
int makeColor (char **addr, const char * const color, ...);

src/readfile.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ readfile (const char * const path, char ***list)
3737

3838
sayMode (&mode);
3939

40+
*list = split = NULL;
41+
4042
if (access (path, 0))
4143
{
42-
*list = split = NULL;
4344
/* Hide error message here { *
4445
say (mode, MSG_E, "access failed: %s\n", strerror (errno));
4546
* } */

src/sudodevd.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ destoryList (char *** const addr)
7171

7272
if (!addr)
7373
{
74-
return -1;
74+
return 1;
7575
}
7676

7777
/* Free *addr */
@@ -209,7 +209,11 @@ sighupHandler (const int signo)
209209
free (list);
210210
list = NULL;
211211
}
212-
pthread_mutex_lock (&mutex);
212+
213+
cleanSudoDev ();
214+
215+
pthread_mutex_unlock (&mutex);
216+
213217
return;
214218
}
215219

@@ -413,7 +417,7 @@ eventloop (void)
413417
pthread_mutex_lock (&mutex);
414418

415419
for (index = 0; sysdevs[index]; ++index);
416-
for (index2 = 0; sudodevs[index2]; ++index2);
420+
for (index2 = 0; sudodevs && sudodevs[index2]; ++index2);
417421
len = index + index2;
418422
if (!(all = (char **)malloc ((len + 1) * sizeof (char *))))
419423
{
@@ -423,7 +427,11 @@ eventloop (void)
423427

424428
memset (all, 0, (len + 1) * sizeof (char *));
425429
memcpy (all, sysdevs, index * sizeof (char *));
426-
memcpy (all + index, sudodevs, index2 * sizeof (char *));
430+
431+
if (sudodevs)
432+
{
433+
memcpy (all + index, sudodevs, index2 * sizeof (char *));
434+
}
427435

428436
if (-1 == msort (all, len, sizeof (char *), cmpStr))
429437
{

0 commit comments

Comments
 (0)