NetBSD Problem Report #57166

From www@netbsd.org  Fri Jan  6 00:09:58 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 5E6321A9239
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  6 Jan 2023 00:09:58 +0000 (UTC)
Message-Id: <20230106000957.6C2BB1A923A@mollari.NetBSD.org>
Date: Fri,  6 Jan 2023 00:09:57 +0000 (UTC)
From: dundas@caltech.edu
Reply-To: dundas@caltech.edu
To: gnats-bugs@NetBSD.org
Subject: tftp does not correctly byte swap the error code for display
X-Send-Pr-Version: www-1.0

>Number:         57166
>Category:       bin
>Synopsis:       tftp does not correctly byte swap the error code for display
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 06 00:10:00 +0000 2023
>Closed-Date:    Fri Jan 06 17:19:18 +0000 2023
>Last-Modified:  Fri Jan 06 17:20:00 +0000 2023
>Originator:     John Dundas
>Release:        
>Organization:
>Environment:
>Description:
When an ERROR packet is returned by tftpd, tftp (the client) does not correctly byteswap the error code prior to display.
>How-To-Repeat:
tftp> binary
tftp> trace
tftp> put /file.txt
sent WRQ <file=/file.txt, mode=octet>
received ERROR <code=2, msg=Access violation>
Error code 512: Access violation
tftp> 

Note that the code "2" is correct; "512" is not correct, it should also be "2".
>Fix:
In both recvfile() and tftp_sendfile(), the incorrect line is:

printf ("Error code %d: %s\n", dp->th_code, dp->th_msg);

I believe this should instead read:

printf ("Error code %d: %s\n", ntohs (dp->th_code), dp->th_msg);

Note that the routine tpacket() does display the error code correctly.

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: christos@NetBSD.org
State-Changed-When: Fri, 06 Jan 2023 12:19:18 -0500
State-Changed-Why:
committed, thanks!


From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57166 CVS commit: src/usr.bin/tftp
Date: Fri, 6 Jan 2023 12:18:56 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Fri Jan  6 17:18:56 UTC 2023

 Modified Files:
 	src/usr.bin/tftp: tftp.c

 Log Message:
 PR/57166: John Dundas: Correct error code byte order in error message


 To generate a diff of this commit:
 cvs rdiff -u -r1.36 -r1.37 src/usr.bin/tftp/tftp.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.