Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
28d8d16f
Commit
28d8d16f
authored
22 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
smb_addmsghdr() and putmsghdr() now returns SMB_BAD_HDR_LEN if the calculated
header length is greater than 0xffff.
parent
1077cbdc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/smblib/smblib.c
+19
-5
19 additions, 5 deletions
src/smblib/smblib.c
with
19 additions
and
5 deletions
src/smblib/smblib.c
+
19
−
5
View file @
28d8d16f
...
...
@@ -611,12 +611,12 @@ int SMBCALL smb_getlastidx(smb_t* smb, idxrec_t *idx)
/****************************************************************************/
/* Figures out the total length of the header record for 'msg' */
/* Returns length */
/* Returns length
*/
/****************************************************************************/
uint
SMBCALL
smb_getmsghdrlen
(
smbmsg_t
*
msg
)
{
int
i
;
int
length
;
int
length
;
/* fixed portion */
length
=
sizeof
(
msghdr_t
);
...
...
@@ -1155,8 +1155,9 @@ int SMBCALL smb_addcrc(smb_t* smb, ulong crc)
/****************************************************************************/
int
SMBCALL
smb_addmsghdr
(
smb_t
*
smb
,
smbmsg_t
*
msg
,
int
storage
)
{
int
i
;
long
l
;
int
i
;
long
l
;
ulong
hdrlen
;
if
(
!
smb
->
locked
&&
smb_locksmbhdr
(
smb
))
return
(
1
);
...
...
@@ -1170,7 +1171,14 @@ int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage)
return
(
i
);
}
msg
->
hdr
.
length
=
smb_getmsghdrlen
(
msg
);
hdrlen
=
smb_getmsghdrlen
(
msg
);
if
(
hdrlen
>
SMB_MAX_HDR_LEN
)
{
/* headers are limited to 64k in size */
sprintf
(
smb
->
last_error
,
"illegal message header length (%lu > %ld)"
,
hdrlen
,
SMB_MAX_HDR_LEN
);
return
(
SMB_BAD_HDR_LEN
);
}
msg
->
hdr
.
length
=
(
ushort
)
hdrlen
;
if
(
storage
==
SMB_HYPERALLOC
)
l
=
smb_hallochdr
(
smb
);
else
if
(
storage
==
SMB_FASTALLOC
)
...
...
@@ -1264,6 +1272,12 @@ int SMBCALL smb_putmsghdr(smb_t* smb, smbmsg_t* msg)
/* Verify that the number of blocks required to stored the actual
(calculated) header length does not exceed the number allocated. */
hdrlen
=
smb_getmsghdrlen
(
msg
);
if
(
hdrlen
>
SMB_MAX_HDR_LEN
)
{
/* headers are limited to 64k in size */
sprintf
(
smb
->
last_error
,
"illegal message header length (%lu > %ld)"
,
hdrlen
,
SMB_MAX_HDR_LEN
);
return
(
SMB_BAD_HDR_LEN
);
}
if
(
smb_hdrblocks
(
hdrlen
)
>
smb_hdrblocks
(
msg
->
hdr
.
length
))
{
sprintf
(
smb
->
last_error
,
"illegal header length increase: "
"%lu (%lu blocks) vs %hu (%lu blocks)"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment