看板 DFBSD_bugs 關於我們 聯絡資訊
This is a multi-part message in MIME format. --------------040500070208040300060408 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/ --------------040500070208040300060408 Content-Type: text/plain; name="hunt.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="hunt.c.diff" --- 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)); --------------040500070208040300060408--