DragonFly BSD
DragonFly bugs List (threaded) for 2004-10
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cu coredumps (fwd)


From: Mark Cullen <mark.cullen@xxxxxxxxxxxxx>
Date: Wed, 27 Oct 2004 18:58:55 +0100

Timour Ezeev wrote:
 	Let me say that I wholeheartedly agree. I wrote it more as a joke rather
 	then a practical solution (didn't you notice :) in the end?). And I also
 	concur that malloc() call must be checked. I missed it :/ and should've
 	caught it right away.

Regards,


I actually noticed I didn't check malloc() after shortly after the second patch post. So I shouldn't worry about freeing it? Suits me :)


It kinda started to get a little messy. I'm sure someone can improve on it. So... is the attached patch sort of alright then?
--
Internet Explorer? Try FireFox at http://www.mozilla.org/products/firefox/
Outlook Express? Try ThunderBird at http://www.mozilla.org/products/thunderbird/
--- hunt.c.old	2004-10-27 16:44:06.000000000 +0100
+++ hunt.c	2004-10-27 18:58:37.000000000 +0100
@@ -59,16 +59,34 @@
 	char *name;
 {
 	register char *cp;
+	char *tmp_cp;
 	sig_t f;
-	int res;
+	int res, cp_len = 0;
 
 	f = signal(SIGALRM, dead);
 	while ((cp = getremote(name))) {
 		deadfl = 0;
-		if ((uucplock = strrchr(cp, '/')) == NULL)
-			uucplock = cp;
-		else
+
+		if ((uucplock = strrchr(cp, '/')) == NULL) {
+			cp_len = strlen(cp) + strlen("/dev/") + 1;
+			tmp_cp = malloc(sizeof(char) * cp_len);
+			if (tmp_cp == NULL) {
+				uucplock = cp;	
+			} else {
+				strncpy(tmp_cp, "/dev/", 6);
+				strncat(tmp_cp, cp, strlen(cp));
+	
+				if ((uucplock = strrchr(tmp_cp, '/')) == NULL) {
+					uucplock = cp;
+				} else {
+					cp = tmp_cp;
+					++uucplock;
+				}
+			}
+		} else {
 			++uucplock;
+		}
+
 		if ((res = uu_lock(uucplock)) != UU_LOCK_OK) {
 			if (res != UU_LOCK_INUSE)
 				fprintf(stderr, "uu_lock: %s\n", uu_lockerr(res));


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]