245 questions
0
votes
2
answers
120
views
C#: Conditional string formatting of interpolated string
Is it possible in C# to have the string formatting of an interpolated string to be performed only if it is required?
Take the following example code:
public class Program
{
private static bool ...
1
vote
0
answers
104
views
Format string vulnerability not showing values on the stack
PROBLEM
I am trying to put together a short demonstration of a simple hack for a presentation about cyber-security. I thought about using a format string vulnerability, and heavily inspired by this ...
1
vote
0
answers
203
views
how to write a large value > 32 bits with a format string exploit %n
I'm working on a challenge that requires me to overwrite a memory address with a libc address, which is usually around 48 bits.
I can write a 32-bit number into an address but with anything larger ...
3
votes
1
answer
130
views
What happens if memory for a format string is shared with one of the arguments of printf? [duplicate]
According to the C Standard, the signature of printf() is:
int printf(const char * restrict format, ...);
As I understand, the meaning of the restrict is that format will be the only reference to the ...
1
vote
2
answers
142
views
Behavior of scanf when first format string character is not whitespace
scanf is supposed to consume and discard any character in the format string that is not part of a conversion specifier. But its behavior seems different when a non-whitespace, non-conversion ...
3
votes
4
answers
790
views
%zu format specifier with C99 not working
I'm willing to print a size_t value using the %zu format specifier in my format string, however, I always get "zu" as an output, rather than the actual value in my size_t variable:
size_t ...
0
votes
0
answers
113
views
Parse C-style format strings in python
Let's say a format string is given as export_%05u.png, we can create a full string in python by supplying an integer like this s = "export_%05u.png"%1. But If we have the format string and ...
0
votes
3
answers
222
views
How to check string with specific format using regex?
I have a specific format string and the result looks like that
X5Y9 Z : true
X1Y20 Z : true
X35Y2 Z : true
X20Y99 Z : true
X01Y05 Z : false
X2Y09 Z : false
X77Y08 Z : false
X05Y9 Z : false
...
-1
votes
2
answers
184
views
Query causing sql injection issue
Type entryEntityType = entry.Entity.GetType();
string tableName = GetTableName(entryEntityType);
string primaryKeyName = GetPrimaryKeyName(entryEntityType);
string deletequery = string.Format("...
0
votes
1
answer
1k
views
How to format a formatted string in Python? Either with .format or f-string
I have a string (sql query) in which I want to pass a variable at one point, then pass another variable at another point (list of variables, but just focusing on one for now).
The expected would be ...
2
votes
1
answer
57
views
“~&” Knows Whether the Ostream is At Line Head?
CL-USER> (progn
(format t "abc~%")
(format t "~&abc"))
abc
abc
NIL
CL-USER>
My guess is: An ostream descriptor always stores the latest char sent ...
1
vote
1
answer
345
views
Pyspark DataFrame : How to map array elements to columns and format string with values
I have a Pyspark DataFrame looking like this :
sdf1 = sc.parallelize([["toto", "tata", ["table", "column"], "SELECT {1} FROM {0}"], "titi", &...
-1
votes
1
answer
246
views
F-string returns file object name [closed]
Trying to understand the output of the following code:
1 #!/usr/bin/python3
2
3 from os.path import exists
4
5 filename = input("What file do you want to erase?: ")
6
7 check =...
0
votes
1
answer
97
views
Test in python format string
I have a python string like this:
expression = "test[1]"
var1 = "{%s}" % expression
str1 = f"{var1}"
print(str1.format(test="world"))
I can only change the ...
1
vote
1
answer
952
views
Format string exploit exercise
consider the following code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void vuln(char *user_input)
{
char buf[128];
strcpy(buf, user_input);
printf(buf)...
2
votes
2
answers
498
views
How to parameterize precision of float on printf format
I have a C program that output values to stdout from measure. I use printf to display them and the format allows me to change the precision
printf("Scan=%d S_0=%.5f S_1=%.5f S_2=%.5f S_3=%.5f&...
1
vote
0
answers
128
views
Can a function be called with printf format string?
Let's consider the functions below:
void func2(void)
{
.
.
.
exit(1);
}
void func1(void)
{
char buf[512];
fgets(buf, 512, stdin);
printf(buf);
exit(1);
}
int main(...
2
votes
3
answers
3k
views
Printing variable number of bytes using format strings with printf
Goal: Print variable number of bytes using a single format specifier.
Environment: x86-64 Ubuntu 20.04.3 LTS running in VM on an x86-64 host machine.
Example:
Let %kmagic be the format specifier I am ...
0
votes
1
answer
819
views
OpenLayers: how to change format of MousePosition coordinates to HDMS?
I'm using the MousePosition control to show the mouse coordinates as it moves but I'm showing an output similar to this: '7.85, 47.98' but I wanted an output like this: '47° 58′ 60.0″ N 7° 50′ 60.0 &...
1
vote
1
answer
116
views
Wrong MYSQL format number in Google Sheets via JDBC
The numbers that I import from an sql database on google sheet are interpreted as duration and not as numbers, more specifically as currencies.
colA
colB
colC
colD
449
1234
29521.00
0.00
449
1234
...
-1
votes
1
answer
191
views
Is there any crucial difference between C Compilers?
I'm a newbie to C programming and I've found this strange behaviour while using the following placeholders specification in the function printf's argument. I get two different results while using an ...
-1
votes
2
answers
2k
views
Strings passed to fmt.Sprintf are Enclosed in Square Brackets
Given the following code snippet
package main
import (
"fmt"
)
type Message string
const (
ConnectRepositoryError Message = "failed to connect %s repository"
)
func ...
-1
votes
1
answer
606
views
DataFormatString TimeSpan - How to show more than 24 hours?
Maybe I'm confusing something but I can't figure out if there is a way to format a TimeSpan that has a value such as: 4.21:02:00 as 117 hours, 2 minutes (change full days to hours)
I have done it ...
1
vote
1
answer
1k
views
Am I able to use "f" to format string and "r" to find files at the same time?
I have this code where I am trying to prompt the user to input a path for a file and depending on the title of the file, it would rename it accordingly. This is what I have so far:
import os
path = ...
0
votes
2
answers
779
views
Nodejs equivalent of c sscanf
I need a function that behaves similar to the behavior of sscanf
For example, let's suppose we have a format string that looks like this (the function I'm looking for doesn't have to be exactly like ...