Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Sat, 16 Nov 2002 10:46:17 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Sat, 16 Nov 2002 10:46:17 -0500 Received: from mailout11.sul.t-online.com ([194.25.134.85]:59556 "EHLO mailout11.sul.t-online.com") by vger.kernel.org with ESMTP id ; Sat, 16 Nov 2002 10:46:16 -0500 Cc: linux-kernel@vger.kernel.org References: From: Olaf Dietsche To: Peter Kjellerstedt Subject: Re: [PATCH] 2.5.47: strdup() Date: Sat, 16 Nov 2002 16:53:00 +0100 In-Reply-To: (Peter Kjellerstedt's message of "Sat, 16 Nov 2002 09:48:57 +0100") Message-ID: <87n0o9340z.fsf@goat.bogus.local> User-Agent: Gnus/5.090005 (Oort Gnus v0.05) XEmacs/21.4 (Honest Recruiter, i386-debian-linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 721 Lines: 19 Peter Kjellerstedt writes: >> +char *strdup(const char *s) >> +{ >> + char *p = kmalloc(strlen(s) + 1, GFP_KERNEL); >> + if (p) >> + strcpy(p, s); >> + >> + return p; >> } >> #endif > > You should make sure s != NULL before doing anything else. Like strcpy(), it's the caller's responsibility to provide a valid pointer. This shouldn't be a problem however, since access to NULL triggers an Oops and thus is quickly detected. Regards, Olaf. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/