From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF3B3C10F03 for ; Thu, 28 Mar 2019 16:02:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B82EB20823 for ; Thu, 28 Mar 2019 16:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726348AbfC1QC2 (ORCPT ); Thu, 28 Mar 2019 12:02:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:44308 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726150AbfC1QC1 (ORCPT ); Thu, 28 Mar 2019 12:02:27 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 82779B9B3; Thu, 28 Mar 2019 16:02:24 +0000 (UTC) Date: Thu, 28 Mar 2019 17:02:19 +0100 From: David Disseldorp To: Steve French Cc: samba-technical , CIFS , linux-fsdevel , Pavel Shilovsky Subject: Re: [PATCH][smbinfo cifsutils] Message-ID: <20190328170219.29c72cbf@echidna.suse.de> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu, 28 Mar 2019 05:05:35 -0500, Steve French wrote: > + /* Now that we know the size, query the list from the server */ > + > + /* Make sure the buf size is big enough even to handle unexpected server behavior */ > + buf = malloc(snap_inf.snapshot_array_size + 300); The buffer length calculations seem pretty arbitrary here, wouldn't it make sense to use something like the following (with a maximum limit)? sizeof(struct smb_snapshot_array) + (snap_inf.number_of_snapshots * GMT_TOKEN_LEN) Cheers, David